var Y = YAHOO, YU = Y.util, Event = YU.Event, Dom = YU.Dom, Lang = Y.lang;

//商旅助手 下拉菜单功能函数 
var menushow;
function showmenu(menu) {
    if (menushow) ssharing.getDom(menushow).style.visibility = "hidden"
    menushow = menu;
    ssharing.getDom(menu).style.visibility = "visible";
}
function hidemenu(menu) { if (ssharing.getDom(menu)) ssharing.getDom(menu).style.visibility = "hidden" }
//------------------------商旅助手 下拉菜单功能函数

//车票列表排序

function trim(str) { //删除左右两端的空格    
    return str.replace(/(^\s*\r)|(\s*\r$)/g, "");
}
//转换器，将列的字段类型转换为可以排序的类型：String,int,float
function convert(sValue, sDataType) {
    switch (sDataType.toLowerCase()) {
        case "int":
            return parseInt(sValue);
        case "float":
            return parseFloat(sValue);
        case "date":
            return new Date(Date.parse(sValue));
        case "begin":
            return getMinute(sValue[0]);
        case "end":
            return getMinute(sValue[1]);
        case "interval":
            return getMinute(sValue[1]) - getMinute(sValue[0]);
        case "$":
            var n = sValue.replace(/\D/g, "");
            n = sValue.match(/\d/g).join("");
            return parseInt(n);
        default:
            return sValue;
    }
}
function getMinute(minute) {
    var time = minute.split(':'), num;
    if (time.length !== 2) return 0;
    time[0] == "00" && (time[0] = 24);
    num = (time[0] - 0) * 60 + (time[1] - 0);
    return num;
}

//排序函数产生器，iCol表示列索引，sDataType表示该列的数据类型
function downSort(iCol, sDataType) {
    return function compareTRs(oTR1, oTR2) {
        var spans1, spans2, minutes1 = [], minutes2 = [],		
        targetTD1 = oTR1.rows[0].cells[iCol], 
        targetTD2 = oTR2.rows[0].cells[iCol];
//oTR1 oTR2两个参数由sort方法传进来 
		sDataType = sDataType.toLowerCase(); 
		//如是出发、到时、飞行时间类型
        if (sDataType == "begin" || sDataType == "end" || sDataType == "interval") {
            spans1 = targetTD1.getElementsByTagName("span"); 
            spans2 = targetTD2.getElementsByTagName("span");
            if (spans1.length !== 2 && spans2.length !== 2) {
                return;
            }
            minutes1[0] = spans1[0].innerHTML;
            minutes1[1] = spans1[1].innerHTML;
            minutes2[0] = spans2[0].innerHTML;
            minutes2[1] = spans2[1].innerHTML;			
        }
        var text1 = spans1 ? minutes1 : (targetTD1.innerText || targetTD1.textContent),
            text2 = spans2 ? minutes2 : (targetTD2.innerText || targetTD2.textContent),
            value1 = convert(text1, sDataType),
            value2 = convert(text2, sDataType);
			
        return value1 < value2 ? 1 : value1 > value2 ? -1 : 0;
    };
}

//初始筛选默认值
//intDefault("depTime","airline");
function intDefault(type1,type2) {
	if(type1 != "" && type1=="depTime")
			Dom.get("depTime_select").selectedIndex="0";
	if(type2 != "" && type2=="airline") {
		Dom.addClass("allAircorp", "current");
		var otherInp = Dom.get("selAirline").getElementsByTagName("input");
		for(var i=0;i<otherInp.length;i++) {
			otherInp[i].checked = false;
		}
	}
}
//绑定事件 jaybird 2012/8/6
var airlines = Dom.getElementsByClassName("airline-input");
Event.on(airlines,"click",function() {
	filterFlight(this);
})
Event.on("depTime_select","change",function(){
	filterFlight(this);	
});

//过滤函数
function filterFlight(e) {
	//alert(e.nodeName);
	var oTable = document.getElementById("tb_1"),//获取表格ID
        oTBody = oTable.tBodies; //获取表格tbody
		tbBodys = []
		rLen = oTBody.length;
	for (var i = 0; i < rLen; i++) {
        tbBodys.push(oTBody[i]);//将表格tBody数据存储入tbBodys数组中
    }
	for(var i=0;i<tbBodys.length;i++) {
		
		if(match(tbBodys[i],e))  {
			Dom.removeClass(tbBodys[i], "dn");
			Dom.addClass(tbBodys[i], "nodn");
		}else{
			Dom.addClass(tbBodys[i], "dn");
			Dom.removeClass(tbBodys[i], "nodn");
		}
	}


function match($tbBody,e) {
	var obj ={};
	obj.depTime = "";
	switch($("depTime_select").selectedIndex){
					case 0: 
						obj.depTime=[0,24];break;//全天
					case 1: 
						obj.depTime=[0,12];break;//上午6-12点
					case 2: 
						obj.depTime=[12,14];break;//中午12-13点
					case 3: 
						obj.depTime=[14,18];break;//下午13-18点
					case 4:
						obj.depTime=[18,24];break;//晚上18-24点
					default: 
						return;
						break;
		}
	obj.airline = getCheckedVal(e);
	return matchAirline($tbBody,obj)&&matchPlaneTime($tbBody,obj);
}
function  getCheckedVal(e) {
	var b="";
	var c="";
	if(e.nodeName =="A") {
		var otherInp = Dom.get("selAirline").getElementsByTagName("input");
		for(var i=0;i<otherInp.length;i++) {
			otherInp[i].checked = false;
		}
	}
	for(var i=0; i<airlines.length; i++) { //检查其它复选框是否被选中
			if  (airlines[i].checked == true) {
				if(b.length >0) 
					b+=",";
				b += airlines[i].value;//把已选中的航班公司建成数组 
				
			} else  {
				if(c.length >0) 
					c+=",";
				c += airlines[i].value;
			}
		}
	if(b)
		Dom.removeClass("allAircorp", "current");
	else
		Dom.addClass("allAircorp", "current");

	return b ? b:c;
}
function matchPlaneTime($tbody,obj) {
		var curTime = parseInt($tbody.rows[0].cells[0].getElementsByTagName("span")[0].innerHTML,10);
		if(curTime >= obj.depTime[0] && curTime < obj.depTime[1]) {
			return true;
		} else {
			return false;
		}
}

function matchAirline($tbody,obj) {
	var curAir = $tbody.rows[0].cells[1].getElementsByTagName("span")[0].innerHTML;
	if(obj.airline.indexOf(curAir) == -1){
		return false;
	} else {
		return true;
	}
}
	reOddTable("nodn","tbody");//重新渲染隔行换色
}
//重新渲染表格奇偶行样数
function reOddTable(classname,type) {
		var len =Dom.getElementsByClassName(classname,type);
		for (var i=0; i < len.length; i++) {
			len[i].className = (i % 2 == 0 ? "trodd" : "treven");
   }
	}

//排序方法
function sortTable(sTableID, iCol, sDataType,flag) {
    var oTable = document.getElementById(sTableID),//获取表格ID
        oTBody = oTable.tBodies, //获取表格tbody
        tbBodys = [], 
		rLen = oTBody.length,//表格行数
        oFragment = document.createDocumentFragment(),//
        arrBodysLen;

	for (var i = 0; i < rLen; i++) {
        tbBodys.push(oTBody[i]);//将表格tBody数据存储入tbBodys数组中
    }
    arrBodysLen = tbBodys.length;
    //按降序排列
    tbBodys.sort(downSort(iCol, sDataType));

    if (flag == "up") {//升序，则从后面开始appendChild 减少reverse开销
        for (var i = arrBodysLen - 1; i >= 0; i--) {
            oFragment.appendChild(tbBodys[i]);
        }
    } if (flag == "down") {//降序
        for (var i = 0; i < arrBodysLen; i++) {
            oFragment.appendChild(tbBodys[i]);
        }
    }
	
    oTable.appendChild(oFragment);
}

//---车票列表排序

//鼠标经过提示框

function crertDiv() {//创建提示DIV层

    var newObj = document.createElement("div");
    newObj.id = "BoxTip";
    newObj.className = "BoxTipCss";
    var obj = "<div class='tips-div' id='ddiv' onMouseOver='keepDisplay()'></div>";
    newObj.innerHTML = obj;
    document.body.appendChild(newObj);
    ssharing.getDom("BoxTip").onmouseover = keepDisplay;
    ssharing.getDom("BoxTip").onmouseout = hideDiv;
    //$("ddiv").style.position = "absolute";
};
function getCurrObjArr(tag, arr) {//获取当前元素的属性

    var obj;
    if (typeof (tag) == "string") obj = ssharing.getDom(tag)
    else if (typeof (tag) == "object") obj = tag
    if (obj.currentStyle) {
        return obj.currentStyle[arr]; //获得IE css属性

    } else if (window.getComputedStyle) {
        return window.getComputedStyle(obj, null)[arr]; //获得FF css属性

    }
}
function setPos(container, target) {
    var containerOW = container.offsetWidth,
            containerOH = container.offsetHeight,
            targetOW = target.offsetWidth,
            targetOH = target.offsetHeight,
            body = document.body, de = document.documentElement,
            bodyWidth = Math.max(body.offsetWidth, de.offsetWidth),
            bodyHeight = Math.max(body.clientHeight, de.clientHeight),
            targetXY = Dom.getXY(target);
    var needChangeX = targetXY[0] + containerOW > bodyWidth,
            needChangeY = targetXY[1] - (document.body.scrollTop || document.documentElement.scrollTop) + targetOH + containerOH > bodyHeight;
    var left = needChangeX ? targetXY[0] + targetOW - containerOW : targetXY[0],
            top = needChangeY ? targetXY[1] - containerOH : targetXY[1] + targetOH;
    return [left, top];
}
function displayDiv(tag) {//显示提示DIV层 id为提示

    if (!ssharing.getDom("ddiv")) crertDiv()
    var DOMmessage = YAHOO.util.Dom.getAttribute(tag, "message");
    ssharing.getDom("ddiv").innerHTML = DOMmessage;
    var openHeight = parseInt(ssharing.getDom("ddiv").offsetHeight);
    var openWidth = parseInt(ssharing.getDom("ddiv").offsetWidth);
    if (tag) {
        var pos = setPos(ssharing.getDom("BoxTip"), tag);
        ssharing.getDom("BoxTip").style.left = (pos[0] - 3 - openWidth / 2) + "px";
        ssharing.getDom("BoxTip").style.top = (pos[1] - 10) + "px";
        //        var left = getCurrObjArr(tag, "left");
        //        var width = parseInt(tag.offsetWidth);
        //        var top = getCurrObjArr(tag, "top");
        //        var height = parseInt(tag.offsetHeight);
        //        if (left == "auto") left = tag.getBoundingClientRect().left + document.documentElement.scrollLeft;
        //        if (top == "auto") top = tag.getBoundingClientRect().top + document.documentElement.scrollTop;
        //        if (YAHOO.util.Dom.getClientHeight() - tag.getBoundingClientRect().bottom < 100) {
        //            $("BoxTip").style.top = top - openHeight - 12 + "px";
        //        } else {
        //            $("BoxTip").style.top = top + 8 + "px"
        //        }
        //        $("BoxTip").style.left = left - openWidth * 0.5 + "px";
    }
    ssharing.getDom("BoxTip").style.visibility = "visible";
}
function keepDisplay() { ssharing.getDom("BoxTip").style.visibility = "visible"; }
function hideDiv() { if (ssharing.getDom("BoxTip")) ssharing.getDom("BoxTip").style.visibility = "hidden"; } //隐藏提示DIV层removeChild
//-----------------------鼠标经过提示

//输入错误提示框
var TipBox = function (elID, type, main, connerID, bg) {
    this.type = type;
    if (YAHOO.lang.isString(elID)) {
        this.elID = elID;
    } else {
        this.elID = Dom.generateId(elID);
    }
    this.main = main;
    this.setDirByType = function () {
        var dir_1, dir_2;
        if (this.type == "top") {
            dir_1 = "bl";
            dir_2 = "tl";
        } else if (this.type == "right") {
            dir_1 = "bl";
            dir_2 = "br";
        } else if (this.type == "bottom") {
            dir_1 = "tl";
            dir_2 = "bl";
        }
        return [dir_1, dir_2];
    }
    var dir = this.setDirByType();
    this.id = this.elID + "_tipbox"
    this.tipBox = new YAHOO.widget.Overlay(this.id, {
        context: [this.elID, dir[0], dir[1], ["beforeShow", "windowResize"]],
        visible: false,
        width: "auto",
        iframe: true,
        zIndex: 20
    });
    var conID = this.elID + "_tipBoxdiv";
    if (bg) {
        var obj = "<div class='AlertouterBox'><div class='alert-div2' id='" + conID + "'></div></div>";
    } else {
        var obj = "<div class='AlertouterBox'><div class='alert-div' id='" + conID + "'></div></div>";
    }
    this.tipBox.setBody(obj);
    if (connerID) this.tipBox.render(YAHOO.util.Dom.get(connerID))
    else this.tipBox.render(document.body);
    this.changePos = function (t) {
        this.type = t;
        var dir = this.setDirByType();
        var context = this.tipBox.cfg.getProperty("context");
        context[1] = dir[0];
        context[2] = dir[1];
        this.tipBox.cfg.setProperty("context", context);
    }
    this.show = function () {
        if (this.main) document.getElementById(conID).innerHTML = this.main;
        if (ssharing.getDom(this.elID + "_tipbox_f")) {
            ssharing.getDom(this.elID + "_tipbox_f").style.display = "block";
        }
        ssharing.getDom(this.id).style.display = "";
        this.tipBox.show();
    } //css=yui-overlay
    this.hide = function () {
        this.tipBox.hide();
        if (Dom.get(this.id)) {
            Dom.get(this.id).style.display = "none";
        }
    } //css=yui-overlay

    var self = this;
    Event.on(document, "click", function () {
        self.hide();
    })
}


//-----------------------输入错误提示

var Event, Dom;
//--------日历控件
document.getElementsByClassName = function (eleClassName) {//自定义方法通过classname获得元素兼容IE
    var getEleClass = []; //定义一个数组

    var myclass = new RegExp("\\b" + eleClassName + "\\b"); //创建一个正则表达式对像
    var elem = this.getElementsByTagName("*"); //获取文档里所有的元素
    for (var h = 0; h < elem.length; h++) {
        var classes = elem[h].className; //获取class对像
        if (myclass.test(classes)) getEleClass.push(elem[h]); //正则比较，取到想要的CLASS对像
    }
    return getEleClass; //返回数组
}
function gettoday() {
    var today = new Date();
    var day = today.getDate();
    var month = today.getMonth() + 1;
    var year = today.getFullYear();
    return month + "/" + day + "/" + year;
}
/*
id:为需要使用日历的页面元素ID
num:为数字 取值为1或者2,其中1显示一个月,2显示两个月,默认显示一个月.
date:所要默认显示的日期（可以为Date 类型，也可以为格式如"2012-05-30"）
onItemSelect:每选中一个日期则会执行这个回调函数
*/
var SS_calender = function (id, num, date, onItemSelect) {

    Event = YAHOO.util.Event;
    Dom = YAHOO.util.Dom;
    tag = ssharing.getDom(id);
    if (!ssharing.getDom("cal-con")) {
        newObj = document.createElement("div");
        newObj.id = "cal-con";
        newObj.style.position = "absolute";
        newObj.style.styleFloat = "right";
        newObj.style.zIndex = 999;
        document.body.appendChild(newObj); //建立完成日历DIV
        if (num == 1 || !num) {
            myCal = new YAHOO.widget.Calendar("cal-con");
        } else if (num == 2) {
            myCal = new YAHOO.widget.CalendarGroup("cal-con");
        }
        myCal.cfg.setProperty("MY_LABEL_YEAR_POSITION", 1);
        myCal.cfg.setProperty("MY_LABEL_MONTH_POSITION", 2);
        myCal.cfg.setProperty("MY_LABEL_YEAR_SUFFIX", "年");
        myCal.cfg.setProperty("MY_LABEL_MONTH_SUFFIX", "月");
        myCal.cfg.setProperty("MONTHS_LONG", ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"]);
        myCal.cfg.setProperty("WEEKDAYS_SHORT", ["日", "一", "二", "三", "四", "五", "六"]);
        myCal.cfg.setProperty("HIDE_BLANK_WEEKS", true);
    }
    if (Object.prototype.toString.call(date) == "[object String]" && date.toLowerCase() == "today") {
        date = gettoday();
    } else if (date == "" || typeof date == "undefined") {
        date = "";
    };
    var sDate = date.split("-"), ret = [];
    for (var i = 0; i < sDate.length; i++) {
        YAHOO.lang.isNumber(parseInt(sDate[i]), 10) && ret.push(sDate[i]);
    }
    if (ret.length == 3) {
        date = ret[1] + "/" + ret[2] + "/" + ret[0];
    }
    myCal.cfg.setProperty("MINDATE", date);
    if (Dom.hasClass("cal-con", "dn")) { Dom.removeClass("cal-con", "dn") }
    function fixPos() {
        var left = Dom.getX(tag);
        var top = Dom.getY(tag);
        var width = parseInt(tag.offsetWidth);
        var height = parseInt(tag.offsetHeight);
        newObj.style.left = left + "px"; //- Math.max(document.documentElement.scrollLeft, document.body.scrollLeft)
        newObj.style.top = top + height + "px"; //- Math.max(document.documentElement.scrollTop, document.body.scrollTop)
    }
    fixPos();
    myCal.render();
    function changeColor() {
        ssharing.getDom(id).style.color = "#333";
    }
    myCal.beforeSelectEvent.subscribe(changeColor, myCal, true);
    /////日历下方快捷按钮
    //var btnBox = document.createElement("div");
    //btnBox.id = "btnBox";
    //$("cal-con").appendChild(btnBox);
    //var btns = "<input onclick='' class='cal_btn' type='button' value='今天' />   <input onclick='' class='cal_btn' type='button' value='关闭' />";
    //$("btnBox").innerHTML = btns;
    myCal.show();
    function cleardd() {
        var coll = Dom.getElementsByClassName("oom", "td", "cal-con");
        Dom.batch(coll, function (el) {
            el.innerHTML = "";
        })
    }
    myCal.selectEvent.subscribe(function () {
        if (myCal.getSelectedDates().length > 0) {
            var selDate = myCal.getSelectedDates()[0];
             tag.value = selDate.getFullYear() + "-" + (selDate.getMonth() + 1).toString().replace(/^(\d)$/,"0$1") + "-" + selDate.getDate().toString().replace(/^(\d)$/,"0$1");
            myCal.hide();
            if (onItemSelect && Object.prototype.toString.call(onItemSelect) == "[object Function]") {
                onItemSelect();
            }
        }
    })
    Event.on(document, "click", function (e) {
        var el = Event.getTarget(e);
        var dialogEl = Dom.get("cal-con");
        if (el != dialogEl && !Dom.isAncestor(dialogEl, el) && el != Dom.get(tag)) {
            Dom.addClass("cal-con", "dn");
            Dom.setStyle("cal-con", "display", "none");
        }
        return;
    });
    cleardd();
}


//---------------------DIV隐藏显现
function DivHiddExp(tag, id) {
    if (typeof (tag) == "string")
        ssharing.getDom(tag).style.display = "none";
    else if (typeof (tag) == "object")
        tag.style.display = "none";
    if (id) ssharing.getDom(id).style.display = "block";
}



/*
带iframe的屏蔽层

urlID:url地址
w:遮罩层宽度
h:遮罩层高度
title:遮罩层标题
*/
var myiframes;
function outIframe(urlID, w, h, title,openFunc,closeFunc) {
    var isInStance = typeof myiframes == "undefined";
    var DiaWid = parseInt(w) + 20; //iframe宽度+2*边框
    if (!isInStance) {
        Dom.setStyle(myiframes.id, "width", DiaWid + "px");
        Dom.setStyle(myiframes.id, "heigth", h ? h : 150 + "px;");
    } else {
        myiframes = new YAHOO.widget.Dialog("myiframes", {
            width: DiaWid + "px",
            heigth: h ? h : 150 + "px;",
            fixedcenter: true,
            close: (openFunc==null)?true:openFunc(),
            draggable: true,
            constraintoviewport: true,
            zindex: 20000,
            modal: true,
            visible: false
        });
        myiframes._doClose = function () {
			//执行右上角关闭按钮的调用函数
	if(closeFunc!=null) closeFunc();
			
            //解决IE6的select无法显示 
            var elSeles = parent.document.getElementsByTagName("select");
            if (elSeles) {
                for (var j = 0; j < elSeles.length; j++) {
                    elSeles[j].style.visibility = "visible";
                }
            }
            //-------------------解决IE6的select无法显示问题
            //解决IE6 IE7在关闭iframe后母页面input无法获得焦点问题
            var inputHidd = parent.document.createElement("input");
            inputHidd.id = "hideIput";
            inputHidd.style.position = "absolute";
            inputHidd.style.left = -5000 + "px";
            document.body.appendChild(inputHidd);
            var t = document.body.scrollTop || document.documentElement.scrollTop;
            document.getElementById("hideIput").focus();
            window.scroll(0, t); //解决 设置focus后 页面滚动条滚到最下面的问题
            //-------------------解决IE6 IE7在关闭iframe后母页面input无法获得焦点问题
            myiframes.hideMask();
            myiframes.hide();
            Dom.setStyle("ssharing_panel", "display", "none");
        }
    }
    var innerCon;
    var heightIframe = parseInt(h) - 28;
    innerCon = "<div id='overflowx' style='overflow:hidden;width:" + w + "px; height: " + heightIframe + "px;'><iframe id='ssharing_panel' scrolling='no' allowTransparency='true' frameborder='0' src='" + urlID + "' name='ssharing_panel' style='width:100%;height: " + heightIframe + "px;'></iframe><div>"
    if (title) myiframes.setHeader(title);
    myiframes.setBody(innerCon);
    //解决IE6的select无法显示
    var elSeles = parent.document.getElementsByTagName("select");
    if (elSeles) {
        for (var j = 0; j < elSeles.length; j++) {
            elSeles[j].style.visibility = "hidden";
        }
    }
    if (isInStance) {
        myiframes.render(document.body);
    }
    //--------------------解决IE6的select无法显示
    myiframes.show();
    Dom.setStyle("ssharing_panel", "display", "block");


    var iframe = Dom.get("ssharing_panel");
    function autoHeight(oIframe) {

        var height;
        if (oIframe.Document) {//ie自有属性
            height = iframe.Document.documentElement.scrollHeight;
        } else if (iframe.contentDocument) {//ie,firefox,chrome,opera,safari
            height = Math.max(iframe.contentDocument.body.scrollHeight, iframe.contentDocument.documentElement.scrollHeight);
        }
        return height;
    }
    function autoWidth(oIframe) {

        var width;
        if (oIframe.Document) {//ie自有属性
            width = iframe.Document.documentElement.scrollWidth;
        } else if (iframe.contentDocument) {//ie,firefox,chrome,opera,safari
            width = Math.max(iframe.contentDocument.body.scrollWidth, iframe.contentDocument.documentElement.scrollWidth);
        }
        return width;
    }
    //根据iframe中页面的内容 是否超出传入的w 或 h 进行添加横向,或者纵向滚动条.
    iframe.onload = iframe.onreadystatechange = function () {
        var overflow = Dom.get("overflowx"),
        overflowH = parseFloat(Dom.getStyle(overflow, "height")),
        overflowW = parseFloat(Dom.getStyle(overflow, "width")),
        allwidth = autoWidth(iframe)
        allheight = autoHeight(iframe);

        if (allheight > overflowH) {
            if (YAHOO.env.ua.ie == 6) {
                Dom.setStyle(overflow, "overflow", "scroll");
            } else {
                Dom.setStyle(overflow, "overflow-y", "scroll");
            }
            if (!YAHOO.env.ua.ie) {
                allheight += 50;
            }
        }
        if (allwidth > overflowW) {
            if (YAHOO.env.ua.ie == 6) {
                Dom.setStyle(overflow, "overflow", "scroll");
            } else {
                Dom.setStyle(overflow, "overflow-x", "scroll");
            }
            if (!YAHOO.env.ua.ie) {
                allwidth += 50;
            }
        }
        Dom.setStyle("ssharing_panel", "height", allheight + "px");
        Dom.setStyle("ssharing_panel", "width", allwidth + "px");
    }
}
//关闭outIframe弹出的窗口
var hideIframe = function () {
	//执行右上角关闭按钮的调用函数
	//if(closeFunc!=null) closeFunc();
	
	
    //解决IE6的select无法显示 
    var elSeles = parent.document.getElementsByTagName("select");
    if (elSeles) {
        for (var j = 0; j < elSeles.length; j++) {
            elSeles[j].style.visibility = "visible";
        }
    }
    //-------------------解决IE6的select无法显示

    //解决IE6 IE7在关闭iframe后母页面input无法获得焦点问题
    var inputHidd = parent.document.createElement("input");
    inputHidd.id = "hideIput";
    inputHidd.style.position = "absolute";
    inputHidd.style.left = -5000 + "px";
    parent.document.body.appendChild(inputHidd);
    var t = parent.document.body.scrollTop || parent.document.documentElement.scrollTop;
    parent.document.getElementById("hideIput").focus();
    //-------------------解决IE6 IE7在关闭iframe后母页面input无法获得焦点问题
    parent.window.scroll(0, t); //解决 设置focus后 页面滚动条滚到最下面的问题
    parent.myiframes.hideMask();
    parent.myiframes.hide();
    parent.document.getElementById("ssharing_panel").style.display = "none";
}

//setMessage.html改变多选框不可用
var StateChange = function (name, state) {
    var obj = document.getElementsByName(name);
    if (state == "n" || state == "N") {
        for (var i = 0; i < obj.length; i++) {
            obj[i].checked = false;
            obj[i].disabled = true;
            obj[i].nextSibling.style.color = "#CCCCCC";
        }
    } else {
        for (var i = 0; i < obj.length; i++) {
            obj[i].disabled = false;
            obj[i].nextSibling.style.color = "#666666";
        }
    }
}
/*
tagName:需要创建的标签
id:设置id
css:设置className
inserttoID:将创建的标签做为该id对应节点的子节点插入 
*/
function creatTags(tagName, id, css, inserttoID) {
    var newObj = document.createElement(tagName);
    if (id) newObj.id = id;
    if (css) newObj.className = css;
    if (inserttoID) ssharing.getDom(inserttoID).appendChild(newObj)
    else document.body.appendChild(newObj)
};
/*
Options参数的配置选项:
defaultData         :    默认显示在下拉列表中的数据
searchData          :    根据用户在本文框输入时的数据在此搜索匹配的数据
input               :    需要设置自能感知的文本框id
initValue           :    设置文本框的placeholder默认文字
width               :    下拉列表宽度
xhrParams           :    该参数为空 用户在本文框输入时会直接在searchData中搜索
                         传入这个参数则会即时向服务器发送请求;
                         xhrParams有以下3个属性:
                         fn     :    发送请求之前会执行这个函数
                         url    :    请求地址
                         params :    请求参数

itemSelectCallBack  :    选中列表某项后的回调函数 有两个参数
                         scope: 自能感知所实例出来的YAHOO.widget.AutoComplete对象
                         args: callBackArgs

callBackArgs        :    itemSelectCallBack回调函数的参数
*/
Ssharing_AutoComplete.Count = 0;
function Ssharing_AutoComplete(Options) {
    this.defaultValue = "中文/拼音";
    this.initValue = this.defaultValue;
    this.defaultData = [];
    if (Options && Options.constructor == Object) {
        for (var p in Options) {
            if (p) {
                this[p] = Options[p];
            }
        }
    }

    this.dataSources = {};
    this.content = "AutoComplete_content" + Ssharing_AutoComplete.Count;
    this.selectData = null;
    this.AllInit();
    this.initEvent();
    Ssharing_AutoComplete.Count++;
}
Ssharing_AutoComplete.prototype.AllInit = function () {
    creatTags("div", this.content);
    this.initAutoComplete();
}
Ssharing_AutoComplete.prototype.getSelected = function () {
    return this.selectData;
}
Ssharing_AutoComplete.prototype.initEvent = function () {
    var self = this, isRemote = this.xhrParams;
    this.ac.itemSelectEvent.subscribe(function (type, args) {
        args[0].getInputEl().value = args[2].C;
        self.selectData = args[2];
        self.itemSelectCallBack &&
            Object.prototype.toString.call(self.itemSelectCallBack) == "[object Function]" &&
            (self.callBackArgs ? self.itemSelectCallBack(args, self.callBackArgs) : self.itemSelectCallBack(args));
    });
    this.ac.textboxFocusEvent.subscribe(function (type, args) {
        if (args[0].getInputEl().value == self.initValue || args[0].getInputEl().value == "") {
            args[0].getInputEl().value = "";
        }
        args[0].sendQuery(args[0].getInputEl().value);
        Dom.setStyle(args[0].getInputEl(), "color", "#333");
    })
    this.ac.textboxBlurEvent.subscribe(function (type, args) {
        var value = args[0].getInputEl().value;
        if (value == "" || value == self.defaultValue) {
            args[0].getInputEl().value = self.initValue;
            Dom.setStyle(args[0].getInputEl(), "color", "#999");
        }
    })
    if (this.xhrParams) {
        Event.on(this.ac.getInputEl(), "keyup", function () {
            var l = this.ac.getInputEl().value;
            if (this.ac.getInputEl().value == "") {
                this.changeDataSource("localjson");
                delete this.ac.generateRequest;
            }
            else {
                this.changeDataSource("xhrarray");
                this.ac.generateRequest = this.setQuery();
            }
            ssharing.isFunction(this.xhrParams.fn) && this.xhrParams.fn.apply(this, arguments);
        }, this, true);
    }
}
Ssharing_AutoComplete.prototype.setData = function (defaultData, searchData) {
    this.defaultData = defaultData;
    this.searchData = searchData;
}
Ssharing_AutoComplete.prototype.setParams = function (params) {
    this.xhrParmas.params = params;
}
Ssharing_AutoComplete.prototype.changeDataSource = function (type) {
    this.ac.dataSource = this.createDataSource(type);
}
Ssharing_AutoComplete.prototype.createDataSource = function (type) {
    this.fields = this.fields || ["C", "E", "S", "ext", "V"];
    var self = this, xhrarray;
    if (type == "localjson") {
        if (!this.dataSources["localjson"]) {
            this.dataSources["localjson"] = new YAHOO.util.FunctionDataSource(function () {
                return self.matchNames.apply(self, arguments)
            }, responseSchema = { fields: this.fields })
        }
        return this.dataSources["localjson"];
    } else if (type == "xhrarray") {
        if (!this.dataSources["xhrarray"]) {
            xhrarray = this.dataSources["xhrarray"] = new YAHOO.util.XHRDataSource(this.xhrParams.url);
            xhrarray.responseType = YAHOO.util.XHRDataSource.TYPE_JSARRAY;
            xhrarray.responseSchema = { fields: this.fields };
            xhrarray.maxCacheEntries = 5;
        }
        return this.dataSources["xhrarray"];
    }
}
Ssharing_AutoComplete.prototype.setQuery = function () {
    var self = this;
    return function (sQuery) {
        return self.xhrParams.params + sQuery;
    };
}
Ssharing_AutoComplete.prototype.initAutoComplete = function () {
    var self = this, xhrParams = this.xhrParams, isRemote = !!xhrParams;
    this.ds = this.createDataSource(isRemote ? "xhrarray" : "localjson");
    this.ac = new YAHOO.widget.AutoComplete(this.input, this.content, this.ds, {
        queryMatchContains: true,
        resultTypeList: false,
        minQueryLength: 0,
        alwaysShowContainer: false,
        animVert: false,
        useIFrame: true
    });
    if (isRemote) {
        this.ac.generateRequest = this.setQuery();
        this.ds.doBeforeParseData = function (oRequest, oFullResponse, oCallback) {
            var data = [];
            if (ssharing.isArray(oFullResponse)) {
                ssharing.each(oFullResponse, function (item, index) {
                    var obj = {};
                    for (var p in item) {
                        if (p) {
                            obj[p] = item[p];
                        }
                    }
                    obj.ext = item;
                    data.push(obj);
                });
                return data;
            }
            return oFullResponse;
        }
    }
    this.ac.formatResult = function () { return self.formatResult.apply(self, arguments) };
    if (this.initValue && this.defaultValue && this.initValue == this.defaultValue) this.ac.setHeader("<span style='font-size:12px; color:#333; padding:0px 10px; text-align:center;'>输入可查看更多城市</span><div style='display:block; margin-bottom:3px;' class='dashe-line'><div/>");
    if (this.ac.getInputEl().value == "") {
        this.ac.getInputEl().value = this.initValue;
        Dom.setStyle(this.ac.getInputEl(), "color", "#999");
    }
    else {
        Dom.setStyle(this.ac.getInputEl(), "color", "black");
    }
    if (this.width && typeof this.width == "number") { Dom.setStyle(this.ac.getContainerEl(), "width", this.width + "px"); }
}

Ssharing_AutoComplete.prototype.formatResult = function (oResultData, sQuery, sResultMatch) {
    var query = sQuery.toLowerCase(), E = oResultData.E, C = oResultData.C, S = oResultData.S || "", // Guard against null value
    Ematch = false, Cmatch = false, Smatch = false, displayEname, displayCname, displaySname;
    var querys = query.replace(/\s+/g, " ").split(" ");
    ssharing.each(querys, function (item, i) {
        if (E.toLowerCase().indexOf(query) > -1) {
            Ematch = true;
        }
        if (C.toLowerCase().indexOf(query) > -1) {
            Cmatch = true;
        }
        if (S.toLowerCase().indexOf(query) > -1) {
            Smatch = true;
        }
    });
    displayEname = Ematch ? this.highlightMatch(E, querys) : E;
    displayCname = Cmatch > -1 ? this.highlightMatch(C, querys) : C;
    displaySname = S ? (Smatch ? "(" + this.highlightMatch(S, querys) + ")" : "(" + S + ")") : "";
    return "<span style='width:40px'>" + displayCname + "</span>" + displaySname;
};
Ssharing_AutoComplete.prototype.highlightMatch = function (full, snippet) {
    ssharing.each(snippet, function (item, i) {
        full = full.replace(item, "<span class='match'>" + item + "</span>");
    });
    return full;
};
Ssharing_AutoComplete.prototype.matchNames = function (sQuery) {
    sQuery = decodeURIComponent(sQuery);
    var i = 0,
		matches = [],
        isEffect = !!sQuery, notfound = true,
        ret = isEffect ? this.searchData : this.defaultData,
        querys = sQuery.replace(/\s+/g, " ").split(" "),
        len = querys.length, query;
    for (; i < len; i++) {
        query = querys[i].toLowerCase();
        if (query) {
            Dom.batch(ret, function (contact) {
                if (isEffect) {
                    if (notfound) {
                        matches.length = 0;
                    }
                    if ((contact.E.toLowerCase().indexOf(query) > -1) ||
			(contact.C.toLowerCase().indexOf(query) > -1) ||
			(contact.S && (contact.S.toLowerCase().indexOf(query) > -1))) {
                        matches.push(contact);
                        notfound = false;
                    }
                }
            });
            if (!notfound) {
                ret = matches.slice(0);
                notfound = true;
            }
        } else if (!query && !isEffect) {//默认数据
            matches = ret;
        }
    }
    return matches;
}
/*
老版本自能感知不支持即时向服务器发送请求
dataSource  数据源名称，数据源是指在city_data.js中定义的数据名称。
inputID     需要智能提示输入的input元素id；
conID       用于容纳感应数据的页面容器id；
name        其他数据开关，没有填写则为城市，填写则为制定的数据。
fn  		需要执行的外部返回函数。
argument    外部函数参数。
*/
ssharing_AC = function (dataSource, inputID, conID, name, fn, argument) {
    var defalutInputName = "中文/拼音";
    if (name) {
        defalutInputName = name; //"请输入姓名"等其他;
    }
    creatTags("div", conID);
    if (!document.getElementById(conID + "ifra")) {
        creatTags("iframe", conID + "ifra", "overselect", conID);
    }
    function disIframe(num) {
        if (!num) {
            ssharing.getDom(conID + "ifra").style.display = "block";
            ssharing.getDom(conID + "ifra").style.height = ssharing.getDom(conID).getElementsByTagName("div")[0].offsetHeight;
        }
        else {
            ssharing.getDom(conID + "ifra").style.height = num + "px";
            ssharing.getDom(conID + "ifra").style.display = "none";
        };
    }
    // Define a custom search function for the DataSource
    var matchNames = function (sQuery) {// Case insensitive matching
        oAC.alwaysShowContainer = false;
        sQuery = decodeURIComponent(sQuery);
        var query = sQuery.toLowerCase(), contact, i = 0,
		matches = [];
        // Match against each name of each contact
        var l_data;
        if (name) l_data = dataSource.length;
        if (!name) {
            var l_citys = dataSource.citys.length, l_hotcitys = dataSource.hotCity.length;
            if (sQuery) {
                for (; i < l_citys; i++) {
                    contact = dataSource.citys[i];
                    if ((contact.E.toLowerCase().indexOf(query) > -1) ||
						(contact.C.indexOf(query) > -1) ||
						(contact.S && (contact.S.toLowerCase().indexOf(query) > -1))) {
                        matches[matches.length] = contact;
                    }
                }
            } else {
                for (var j = 0; j < l_hotcitys; j++) {
                    matches[j] = dataSource.hotCity[j];
                }
            }
        } else {
            if (sQuery) {
                for (; i < l_data; i++) {
                    contact = dataSource[i];
                    if ((contact.C.toLowerCase().indexOf(query) > -1) ||
						(contact.S && (contact.S.toLowerCase().indexOf(query) > -1))) {
                        matches[matches.length] = contact;
                    }
                }
            }
            else {
                if (name != "请输入姓名" && name != "请输入名称") {
                    for (var j = 0; j < l_data; j++) {
                        matches[j] = dataSource[j];
                    }
                }
            }
        }
        return matches;
    };
    // Use a FunctionDataSource
    var oDS = new YAHOO.util.FunctionDataSource(matchNames);
    oDS.responseSchema = {
        fields: ["C", "E", "S"]
    }
    // Instantiate AutoComplete
    var oAC = new YAHOO.widget.AutoComplete(inputID, conID, oDS);
    oAC.queryMatchContains = true;

    if (!name) oAC.setHeader("<span style='font-size:12px; color:#333; padding:0px 10px; text-align:center;'>输入可查看更多城市</span><div style='display:block; margin-bottom:3px;' class='dashe-line'><div/>");
    oAC.resultTypeList = false;
    oAC.autoHighlight = true;
    oAC.minQueryLength = 0;
    oAC.alwaysShowContainer = false;
    oAC.animVert = false;
    //	oAC.dataErrorEvent.subscribe(function(){//返回结果错误
    //										  								  
    //	});
    oAC.itemSelectEvent.subscribe(function (sType, aArgs) {
        if (oAC.getInputEl().value == "") {
            oAC.alwaysShowContainer = true;
            disIframe();
            oAC.sendQuery("");
        } else {
            disIframe(5);
            oAC.alwaysShowContainer = false;
            if (fn) fn(aArgs, argument); //执行回调函数；
        }
        return;
    });
    YAHOO.util.Event.addListener(inputID, "click", function () {
        if (oAC.getInputEl().value != "" && oAC.getInputEl().value != defalutInputName && oAC.getInputEl().value != oAC.defaultCity) {
            oAC.sendQuery(oAC.getInputEl().value);
        } else {
            oAC.sendQuery("");
            disIframe();
        }
        if (oAC.getInputEl().value == defalutInputName) {
            oAC.getInputEl().value = "";
            Dom.setStyle(oAC.getInputEl(), "color", "#333");
        }
    });

    oAC.textboxBlurEvent.subscribe(function () {
        if (oAC.getInputEl().value == "") {
            oAC.getInputEl().value = defalutInputName;
            Dom.setStyle(oAC.getInputEl(), "color", "#999");
        }
        disIframe(5);
    });
    oAC.containerExpandEvent.subscribe(function () {
        disIframe();
    });
    oAC.textboxKeyEvent.subscribe(function (e, a, c) {
        if (c._openDelayID != -1) {
            clearInterval(c._openDelayID);
        }
        c._openDelayID = setInterval(function () {
            if (c._openDelayID && !c.isContainerOpen()) {
                disIframe();
                clearInterval(c._openDelayID);
            }
        }, (c.queryDelay * 1001));
    }, oAC);


    //Custom formatter to highlight the matching letters
    oAC.formatResult = function (oResultData, sQuery, sResultMatch) {
        var query = sQuery.toLowerCase(), E = oResultData.E, C = oResultData.C, S = oResultData.S || "", // Guard against null value
            EnameMatchIndex = E.toLowerCase().indexOf(query),
            CnameMatchIndex = C.toLowerCase().indexOf(query),
            SnameMatchIndex = S.toLowerCase().indexOf(query),
            displayEname, displayCname, displaySname;
        if (EnameMatchIndex == 0) {
            displayEname = highlightMatch(E, query, EnameMatchIndex);
        } else {
            displayEname = E;
        }
        if (CnameMatchIndex == 0) {
            displayCname = highlightMatch(C, query, CnameMatchIndex);
        } else {
            displayCname = C;
        }
        if (SnameMatchIndex == 0) {
            displaySname = (S || S.length > 0) ? "(" + highlightMatch(S, query, SnameMatchIndex) + ")" : "";
            //"(" + highlightMatch(S, query, SnameMatchIndex) + ")";//
        } else {
            displaySname = S ? "(" + S + ")" : "";
        }
        disIframe();
        return "<span style='width:40px'>" + displayCname + "</span>" + displaySname;
    };
    // Helper function for the formatter
    var highlightMatch = function (full, snippet, matchindex) {
        return full.substring(0, matchindex) + "<span class='match'>" + full.substr(matchindex, snippet.length) + "</span>" + full.substring(matchindex + snippet.length);
    };
    disIframe();
    return {
        oDS: oDS,
        oAC: oAC
    };
};

function ableEl(id, css) {
    ssharing.getDom(id).disabled = "";
    ssharing.getDom(id).className = css;
}
function disableEl(id, css) {
    ssharing.getDom(id).disabled = "disabled";
    ssharing.getDom(id).className = css;
}

/*
简单弹出框 没有iframe
elID    弹出框id；
width   出框宽度；
model   是否有遮罩 true为有遮罩，false为没有遮罩，默认为没有；
main    弹出框显示的内容，可以包含HTML代码；
head    弹出框标题，可以包含HTML代码；
hsclose 是否显示关闭按钮
btns    按钮数组
*/
var SimpleDialog = function (elID, width, model, main, head, hsclose, btns) {
    // Define various event handlers for Dialog
    if (YAHOO.lang.isString(elID)) {
        this.diaID = elID + "_simple";
    } else {
        this.diaID = Dom.generateId(elID) + "_simple";
    }
    this.width = width;
    this.main = main;
    this.head = head;
    this.model = model;
    this.close = true;
    if (hsclose) this.close = false;
    var dialog = new YAHOO.widget.SimpleDialog(this.diaID,
					 { width: this.width + "px",
					     fixedcenter: true,
					     visible: false,
					     modal: this.model,
					     draggable: true,
					     constraintoviewport: true,
					     close: this.close,
					     constraintoviewport: true,
					     buttons: btns ? btns : false
					 });
    this.dialog = dialog;
    this.show = function () {
        dialog.setHeader(this.head);
        dialog.setBody(this.main);
        dialog.render(document.body);
        dialog.show();
        YAHOO.util.Dom.setStyle(this.diaID, "overflow", "hidden");
    }
    this.hide = function () {
        dialog.hide();
    }
    dialog._doClose = function () {
        dialog.hide();
        //Dom.setStyle(dialog.element.id, "display", "none");
    }
}
//商旅管理 -组织结构-领导名单折叠函数
function GetDeptId(tableid) {
    var table = ssharing.getDom(tableid);
    var trs = table.getElementsByTagName("tr");

    var deptsid = [];
    for (var i = 0; i < trs.length; i++) {
        deptsid[i] = trs[i].id;
    }
    return deptsid;
}
function DeptMatch(tableid, myid) {
    var deptids = GetDeptId(tableid);
    //var myidlength = myid.length;//7
    var myidlength = myid.split("_").length;
    var sundept = [];
    for (var j = 0; j < deptids.length; j++) {
        if (deptids[j].indexOf(myid) >= 0 && deptids[j].split("_").length > myidlength) {
            sundept[j] = deptids[j];
        }
    }
    return sundept;
}

//用于截取控件的名称，例如控件的名称  DomName=dept1_1_1，如果Begin=0，End=2，splitFlag=‘_’，则截出来 为dept1_1
function SubDomName(DomName, Begin, End, splitFlag) {
    var retval = "";
    var arr = DomName.split(splitFlag);
    for (var i = Begin; i < End; i++) {
        retval += (retval.length == 0) ? arr[i] : splitFlag + arr[i];
    }
    return retval;
}


function DisplayBlock(id) { ssharing.getDom(id).style.display = "" }
function DisplayNone(id) { ssharing.getDom(id).style.display = "none" }

//表格移入移出时改变颜色
var TableThrough = {
    Event: YAHOO.util.Event,
    Dom: YAHOO.util.Dom,
    init: function (tableName, filter, hoverClsName) {
        hoverClsName = hoverClsName || "trhover";
        tableName = ssharing.getDom(tableName);
        var trs = Dom.getElementsBy(function (el) {
            return Dom.hasClass(el, filter) ? false : true;
        }, "tr", tableName);
        this.Event.on(trs, "mouseover", function (e, scope) {
            scope.Dom.addClass(this, hoverClsName);
        }, this);
        this.Event.on(trs, "mouseout", function (e, scope) {
            scope.Dom.removeClass(this, hoverClsName);
        }, this);
    }
}

/*
settings配置属性:
content         :<String | Array>提示层的内容
eventSouce      :<String | Array | NodeList>触发提示层显示的元素ID(可以是一组元素的ID)
width           :<Number>提示层的宽度
closeSouce      :<String | Array>触发关闭事件的元素ID
eventType       :<String>关闭事件类型
repeat          :<Boolean>不会根据content与eventSouce 传入的为数组而创建多份HTML.每次显示出的都是同一个提示层.仅仅改变提示层的显示位置而已.
*/
newTipBox.invokCount = 0;
newTipBox.OVERLAYNAME = "overlay";
function newTipBox(settings) {
    this.clearTimer = null;
    this.opened = false;
    this.initSettings = settings || {};
    this.fixTipBoxIconHeight = 8;
    this.fixTipBoxIconWidth = 10;
    this.dirStyle = {
        left: "left",
        right: "right",
        middle: "middle",
        top: "top",
        bottom: "bottom"
    }
    if (!settings.getContentType && (!settings.content || !settings.eventSouce)) {
        return;
    }
    if (!settings.repeat &&
        this.isArray(settings.content) &&
        this.isArray(settings.eventSouce)) {
        var arr = [], i = 0, o = {};
        if (settings.content.length == settings.eventSouce.length) {
            for (; i < settings.content.length; i++) {
                o.content = settings.content[i];
                o.eventSouce = settings.eventSouce[i];
                this.cover(settings, o);
                arr.push(new this.constructor(o)); //可能被继承，所以调用其构造器
            }
        }
        return arr;
    }
    this.cover(this.initSettings, this);
    var evevtEl = Dom.get(settings.eventSouce);
    if (!!settings.repeat && this.isArray(settings.eventSouce)) {
        this.boxInit(this.content, this.width);
        var i, len = settings.eventSouce.length;
        for (var i = 0; i < len; i++) {
            this.EventInit(settings.eventSouce[i]);
        }
    }else if (YAHOO.lang.isString(settings.content) && evevtEl) {
        this.boxInit(this.content, this.width);
        this.EventInit(this.eventSouce);
    }
}


newTipBox.prototype.containerCss = "msgbox";
newTipBox.prototype.delay = 0;
newTipBox.prototype.outSide = true;
newTipBox.destroy = function () {
    for (var i = 1, overlay; i <= newTipBox.invokCount; i = i + 1) {
        overlay = Dom.get(newTipBox.OVERLAYNAME + i);
        !YAHOO.lang.isNull(overlay) && overlay.parentNode.removeChild(overlay);
    }
    newTipBox.invokCount = 0;
}
newTipBox.prototype.cover = function (op, opts) {
    for (var p in op) {
        if (p && !(p in opts)) {
            opts[p] = op[p];
        }
    }
}
newTipBox.prototype.isArray = function (arry) {
    return arry &&
            Object.prototype.toString.call(arry) == "[object Array]" &&
            typeof arry[0] !== "undefined";
}
newTipBox.prototype.getContentMethod = function (t) {
    var method = { "next": Dom.getNextSibling,
        "prev": Dom.getPreviousSibling
    }
    if (YAHOO.lang.isFunction(this.getContentType)) {
        return this.getContentType(t, this);
    } else if (YAHOO.lang.isString(this.getContentType) && this.getContentType in method) {
        var el = method[this.getContentType](t);
        return el && el.value;
    }
    return "";
}
newTipBox.prototype.hide = function (box) {
    this.picbox.hide();
    this.opened = false;
    //Dom.setStyle(this.picbox.id, "display", "none");
}
newTipBox.prototype.setContentHtml = function (html) {
    Dom.getElementsByClassName("box_text", "div", this.picbox.id)[0].innerHTML = html;
}
newTipBox.prototype.moveTOXY = function (target) {
    var ret = Dom.getXY(target),
        x = ret[0], y = ret[1], overlay = Dom.get(this.picbox.id),
        bodyw = Math.min(document.body.offsetWidth, document.documentElement.offsetWidth),
        bodyh = Math.min(document.body.clientHeight, document.documentElement.clientHeight),
        targetw = Dom.get(target).offsetWidth,
        targeth = Dom.get(target).offsetHeight,
        targetXY = Dom.getXY(target),
        tipboxw = overlay.offsetWidth,
        tipboxh = overlay.offsetHeight,
        changeDirX = x + tipboxw + targetw > bodyw,
        changeDirY = y - (document.body.scrollTop || document.documentElement.scrollTop) + tipboxh + targeth > bodyh,
        dir = this.dirStyle, xx, yy, dirs = [];

    dirs[0] = changeDirX ? dir.right : dir.left;
    dirs[1] = changeDirY ? dir.top : dir.bottom;

    Dom.get(this.top).className = "";
    dirs = this.defaultdir || dirs;

    xx = dirs[0] == dir.left ? (targetXY[0] + targetw - this.fixTipBoxIconWidth - targetw / 2)
                             : dirs[0] == dir.middle ? targetXY[0] + targetw / 2 - (tipboxw - this.fixTipBoxIconWidth) / 2
                             : (targetXY[0] - tipboxw + this.fixTipBoxIconWidth + targetw / 2);
    yy = dirs[1] == dir.top ? (targetXY[1] - tipboxh - this.fixTipBoxIconHeight) : (targetXY[1] + targeth + this.fixTipBoxIconHeight);
    Dom.addClass(this.top, dirs.join(''));

    return [xx, yy];
}
newTipBox.prototype.show = function (target) {
    var self = this, xy, xx, yy;
    this.outSide = false;
    target = target || this.eventSouce;
    this.beforShow(target);
    var picbox = this.picbox;
    if (!!this.getContentType) {
        tipcontent = this.getContentMethod(target);
        if (YAHOO.lang.isNull(tipcontent) ||
           YAHOO.lang.isUndefined(tipcontent) ||
           tipcontent == "") {
            return;
        }
        this.setContentHtml(tipcontent);
        Dom.setStyle(picbox.id, "display", "block");
    }

    xy = this.moveTOXY(target);
    xx = xy[0];
    yy = xy[1];

    if (!!this.delay) {
        setTimeout(function () {
            if (!self.outSide) {
                if (self.opened) {
                    self.picbox.show();
                }
                self.picbox.moveTo(xx, yy);
            }
        }, this.delay);
    } else {
        if (this.opened) {
            this.picbox.show();
        }
        this.picbox.moveTo(xx, yy);
    }
}
newTipBox.prototype.MouseOut = function (e, scope) {
    var s = e.toElement || e.relatedTarget,
    nothide = Dom.getElementsByClassName(this.containerCss, "div", scope.picbox.id)[0];
    this.outSide = true;
    if (!(
            Dom.isAncestor(scope.eventSouce, s) || Dom.isAncestor(nothide, s) ||
            scope.eventSouce === s || nothide === s
        )) {
        //scope.clearTimer = setTimeout(function () {
        scope.hide(scope.picbox);
        //}, 500);
    }

    this.opened = false;
}
newTipBox.prototype.beforShow = function () {

}
newTipBox.prototype.EventInit = function (target) {
    var self = this,
        nothide = Dom.getElementsByClassName(this.containerCss, "div", self.picbox.id)[0];
    if (!this.eventType) {
        Event.on(nothide, "mouseout", self.MouseOut, self, true);
        Event.on(target, "mouseout", self.MouseOut, self, true);
        Event.on(target, "mouseover", function (e, box) {
            clearTimeout(box.clearTimer);
            box.clearTimer = null;
            self.opened = true;
            box.show(this);
        }, self);
        Event.on(nothide, "mouseover", function (e, box) {
            clearTimeout(box.clearTimer);
            box.clearTimer = null;
        }, self);
    }
    else {
        var cl = self.closeSouce;
        if (cl && target !== cl) {
            Event.on(target, this.eventType, function (e, box) {
                self.opened = true;
                self.show(target);
            });
            Event.on(cl, self.eventType, function () {
                this.hide(this.picbox);
                this.opened = false;
            }, self, true);
        } else {
            Event.on(target, self.eventType, function (e, box) {
                if (Dom.getStyle(box.id, "visibility") == "hidden") {
                    self.opened = true;
                    self.show(target);
                } else {
                    self.hide(box);
                    self.opened = false;
                }
                Event.stopEvent(e);
            }, self.picbox, true);
        }
        Event.on(window, "resize", self.fixIEWindowEvent, { scope: self, name: "ResizeEnd", speed: 1 }, true);
        Event.on(window, "scroll", self.fixIEWindowEvent, { scope: self, name: "ScrollEnd", speed: 100 }, true);
    }
}
newTipBox.prototype.fixIEWindowEvent = function (e) {
    var self = this,
    target = self.scope.eventSouce;
    if (YAHOO.env.ua.ie > 0) {//保证IE只执行一次
        if (!window[self.name]) {
            window[self.name] = -1;
        }

        clearTimeout(window[self.name]);

        window[self.name] = setTimeout(function () {
            self.scope.show(target);
        }, self.speed);
    } else {
        this.scope.show(target);
    }
}
newTipBox.prototype.boxInit = function (content, width) {
    newTipBox.invokCount++;
    this.picbox = new YAHOO.widget.Overlay(newTipBox.OVERLAYNAME + newTipBox.invokCount, {
        visible: false,
        width: "auto", zIndex: 101,
        autofillheight: true
    });
    this.top = "top" + newTipBox.invokCount;
    width = !!this.scroll ? (width + 26) : width;
    width = YAHOO.lang.isUndefined(width) ? "" : width;
    var html = [];
    html[html.length] = '<div class="' + this.containerCss + '" style="width:' + width + 'px">';
    html[html.length] = '   <div id="' + this.top + '">';
    html[html.length] = '        <div class="icon"></div>';
    html[html.length] = '   </div>';
    html[html.length] = '   <b class="boxtitle">';
    html[html.length] = '       <b class="item1"></b>';
    html[html.length] = '       <b class="item2"></b>';
    html[html.length] = '       <b class="item3"></b>';
    html[html.length] = '   </b>';
    html[html.length] = '   <div class="box_text" style="' + (this.scroll && this.height ? "overflow:auto;height:" + this.height + "px;" : "") + '">';
    html[html.length] = content;
    html[html.length] = '   </div>';
    html[html.length] = '   <b class="boxfoot">';
    html[html.length] = '       <b class="item3"></b>';
    html[html.length] = '       <b class="item2"></b>';
    html[html.length] = '       <b class="item1"></b>';
    html[html.length] = '   </b>';
    html[html.length] = '</div>';
    this.picbox.setBody(html.join(''));
    this.picbox.render(document.body);
    Dom.setStyle(this.picbox.id, "position", "absolute");
    Dom.setStyle(this.picbox.id, "visibilty", "hidden");
}


/*
类似热门城市提示框 ssharing_hotCityInit不太灵活.国内酒店-酒店位置 有用到
opts配置属性：
callback    ：选中某项后的回调参数
start       :文本框ID
container   :内容层ID
*/
function ssharing_hot(opts) {
    var defaults = {
        width: 200,
        height: 200
    }
    ssharing.extend(defaults, opts);
    this.opened = true;
    this.overlay = null;
    this.container = null;
    this.start = null;
    this.end = null;
    this.callback = null;
    this.init(defaults);
}
ssharing_hot.prototype = {
    HOT_TITLE: "ssharing_hot_title",
    HOT_CONTAINER: "ssharing_hot_container",
    HOT_A: "ssharing_hot_a",
    init: function (opts) {
        this.setOptions(opts);
        if (!this.start) return;
        if (this.opened) {
            this.createHtml();
            this.initYUIControl();
            this.initEvent();
            this.opened = false;
        }
    },
    setOptions: function (opts) {
        ssharing.extend(this, opts);
    },
    createHtml: function () {
        if (!this.container) {
            var div = document.createElement("div");
            var html = "<div class='" + this.HOT_TITLE + "'>a</div>"
                    + "<div class='" + this.HOT_CONTAINER + "'>b</div>";
            div.innerHTML = html;
            this.container = document.body.appendChild(div);
            Dom.generateId(this.container);
        } else {
            this.container = Dom.get(this.container);
        }
    },
    initEvent: function () {
        var linkContainer = Dom.getElementsByClassName(this.HOT_CONTAINER, "div", this.container)[0];
        //保存YAHOO.widget.AutoComplete 注册的focus事件处理
        var acFocusEvent = Event.getListeners(this.start, "focus");
        var self = this;
        Event.removeListener(this.start, "focus");

        Event.on(this.start, 'blur', function (e) {
            this.hide();
        }, this, true);

        Event.on(this.start, 'focus', function (e) {
            if (self.start.value == "中文/拼音") {
                self.start.value = "";
            } else {
                if (e.type != "keyup") {
                    Dom.get(self.start).select();
                }
            }
            Dom.setStyle(self.start, "color", "#333");
            self.show();
        }, this, true);

        //执行YAHOO.widget.AutoComplete 注册的focus事件处理
        Event.on(this.start, "keyup", function (e) {
            var i, len, item;
            if (YAHOO.widget.AutoComplete && acFocusEvent) {
                for (i = 0, len = acFocusEvent.length; i < len; i += 1) {
                    item = acFocusEvent[i];
                    item.fn(e, item.obj);
                }
            }
            this.hide();
        }, this, true);

        Event.on(linkContainer, "mousedown", function (e) {
            var input = Dom.get(this.start),
                target = Event.getTarget(e);
            if (!input) {
                return false;
            }
            Dom.setStyle(input, "color", "#333");


            while (target.tagName && target.tagName.toLowerCase() != "a") {
                target = target.parentNode;
                if (!target.tagName || target.tagName.toLowerCase() == "html") {
                    return;
                }
            }

            input.value = target.innerHTML;
            input.focus();
            this.hide();
            this.callback && ssharing.isFunction(this.callback) && this.callback(input, this);
        }, this, true);
    },
    initYUIControl: function () {
        this.overlay = new YAHOO.widget.Overlay(Dom.generateId(), {
            context: [this.start, "tl", "bl", ["beforeShow", "windowResize"]],
            visible: false,
            width: this.width + "px",
            height: this.height + "px",
            iframe: true,
            zIndex: 200
        });
        this.overlay.setBody(this.container);
        this.overlay.render(document.body);
        Dom.setStyle(this.overlay.id, "position", "absolute");
        //this.show();
    },
    show: function () {
        Dom.setStyle(this.overlay.element.id, "display", "block");
        this.overlay.show();
    },
    hide: function () {
        Dom.setStyle(this.overlay.element.id, "display", "none");
        this.overlay.hide();
    }
}

//热门城市输入框处理:传参类型为1、string/array 2、弹出热门城市框的id（string）3,是否有多个洲的城市切换boolean 
//如果仅需要热门城市效果 那么使用 hotCityInit("startCity","id",false);
//如果洲际切换效果 那么使用 hotCityInit("startCity","id",true);
//一定要在该input框的new ssharing_AC前执行。
function ssharing_hotCityInit(cities, hotCity_tip, bl, callback) {
    var me, elInput = Dom.get(cities),
        htmlTemplate = Dom.get(hotCity_tip || "hotCity_tip"),
        bl = typeof bl === "undefined" ? true : bl;
    if (!cities || !hotCity_tip) {
        return;
    }
    if (ssharing.isFunction(bl)) {
        callback = bl;
    }
    if (this instanceof ssharing_hotCityInit) {
        this.init({
            elInput: elInput,
            htmlTemplate: htmlTemplate,
            mode: bl,
            callback: callback
        });
    } else {
        return me = new ssharing_hotCityInit(cities, hotCity_tip, bl, callback);
    }
}
ssharing_hotCityInit.prototype = {
    init: function (options) {
        ssharing.copy(options, this);
        this.ACFocusEvent = null;
        this.createOverLay();
        this.eventInit();
    },
    hotCityShow: function () {
        if (this.elInput.value == "中文/拼音") {
            this.elInput.value = "";
        } else {
            this.elInput.select();
        }
        Dom.setStyle(this.elInput, "color", "#333");
        this.tipBox_hotCity.show();
    },
    eventInit: function () {
        var tdA = Dom.getElementsByClassName("hotCityA", "a", this.htmlTemplate),
        tabUl, listDiv, tabs, list, door;
        //移除this.elInput获得焦点时的智能感知控件显示

        this.ACFocusEvent = Event.getListeners(this.elInput, "focus");
        Event.removeListener(this.elInput, "focus");


        Event.removeListener(this.elInput, "click");
        Event.on(this.elInput, "click", this.hotCityShow, this, true);
        Event.on(this.elInput, "keyup", this.keyUpFun, this, true);
        Event.on(document, "click", this.documentClick, this, true);
        Event.on(tdA, "click", this.itemClick, this, true);
        if (this.mode) {//带有选项卡的操作
            tabUl = Dom.getElementsByClassName("hotCityNav", "ul", this.htmlTemplate);
            listDiv = Dom.getElementsByClassName("hotMain", "div", this.htmlTemplate);
            if (tabUl[0] && listDiv[0]) {
                tabs = tabUl[0].getElementsByTagName("li");
                list = listDiv[0].getElementsByTagName("div");
                door = new SlidingDoors(tabs, list, "noBottom", "");
                ssharing.each(tabs, function (item, i) {
                    item.index = i;
                    item.onclick = this.onChange;
                }, door);
            }
        }
    },
    /*
    * 当监测到keyup事件时 必须执行AutoComplete 的_onTextboxFocus事件 
    * 其事件中会将进行一些操作 为保证 AutoComplete的_populateList正常运行 
    * 并且隐藏热点城市列表
    */
    keyUpFun: function (e) {
        var i, len, item;
        if (YAHOO.widget.AutoComplete) {
            for (i = 0, len = this.ACFocusEvent.length; i < len; i += 1) {
                item = this.ACFocusEvent[i];
                item.fn(e, item.obj);
            }
        }
        this.hotHideByKeyUp();
    },
    itemClick: function (e) {
        if (!this.elInput) {
            return false;
        }
        Dom.setStyle(this.elInput, "color", "#333");
        this.elInput.value = Event.getTarget(e).innerHTML;
        this.elInput.focus();
        this.hotHideByKeyUp();
        this.callback && ssharing.isFunction(this.callback) && this.callback(this.elInput);
    },
    documentClick: function (e) {
        var target = Event.getTarget(e);
        if (Dom.isAncestor(this.htmlTemplate, target) || this.elInput === target) {
            if (target.nodeName.toLowerCase() != "a" && this.elInput.value != "中文/拼音") {
                this.elInput.select();
            }
        } else {
            this.hotHideByKeyUp();
        }
    },
    hotHideByKeyUp: function () {
        this.tipBox_hotCity.hide();
    },
    createOverLay: function () {
        var tipBoxId = this.htmlTemplate.id + "_overLay0";
        for (var i = 0; ; i++) {
            if (!Dom.get(this.htmlTemplate.id + "_overLay" + i)) {
                tipBoxId = this.htmlTemplate.id + "_overLay" + i;
                break;
            }
        }

        this.tipBox_hotCity = new YAHOO.widget.Overlay(tipBoxId, {
            context: [this.elInput, "tl", "bl", ["beforeShow", "windowResize"]],
            visible: false,
            width: "318px",
            height: "200px",
            iframe: true,
            zIndex: 200000
        });
        var tipInnerHTML = Dom.get(this.htmlTemplate.id).innerHTML;
        this.tipBox_hotCity.setBody(tipInnerHTML);
        this.tipBox_hotCity.render(document.body);
        Dom.setStyle(tipBoxId, "position", "absolute");
        Dom.setStyle(tipBoxId, "left", "0px");
        Dom.setStyle(tipBoxId, "top", "0px");
        this.htmlTemplate = Dom.get(tipBoxId);
    }
}

/*查找父级元素 
el：     从el元素开始
tag：    指定查找到tag元素结束
letgo：  查找el开始匹配letgo次的元素
dobreak：指定到dobreak元素跳出循环
*/
function getParentTo(el, tag, letgo, dobreak) {
    var i = 0, letgo = letgo || 0;
    while ((el = el.parentNode)) {
        if (dobreak && el.tagName.toLowerCase() === dobreak) {
            break;
        }
        if (el.tagName.toLowerCase() === tag) {
            i++;
            if (i > letgo) {
                return el;
            }
        }
    }
}
/*
简单滑动门方法
tabsItem<NodeList>：     标签集合
containsItem<NodeList>： 标签对应内容层集合
on<String>：             激活时的样式
off<String>：            常态下的样式
fn<Function>:            选中时的回调函数
*/
function SlidingDoors(tabsItem, containsItem, on, off, fn) {
    this.tabs = tabsItem;
    this.contains = containsItem;
    var _this = this;
    this.onChange = function () {
        for (var i = 0; i < tabsItem.length; i++) {
            var isCurrent = this == _this.tabs[i];
            var ret = isCurrent ? [this, on] : [_this.tabs[i], off];
            _this.setClassName.apply(ret[0], [ret[1], isCurrent]);
        }
    }
    this.setClassName = function (className, isCurrent) {
        //containsItem[this.index].className = className;
        var ak = containsItem[this.index];
        containsItem[this.index].style.display = isCurrent ? "block" : "none";
        this.className = className;
        isCurrent && (fn && (Object.prototype.toString.call(fn) == "[object Function]" && fn.call(this, _this)));
    }
}
function tabdoor(title, content, pop, title_tag, content_tag) {
    var tabs = document.getElementById(title).getElementsByTagName(title_tag || "dd"),
            content = document.getElementById(content).getElementsByTagName(content_tag || "ul"),
            door, ret;
    if (pop === true) {
        ret = ssharing.nodeListToArray(tabs);
        ret.pop();
    } else {
        ret = tabs;
    }
    door = new SlidingDoors(ret, content, 'current', '')
    for (var i = 0; i < ret.length; i++) {
        ret[i].index = i;
        ret[i].onclick = door.onChange;
    }
}

var ssharing = ssharing || {};
ssharing.rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g;
ssharing.trim = function (text) {
    return (text || "").replace(ssharing.rtrim, "");
}
ssharing.getDom = function (id) {
    return typeof id == "string" ? document.getElementById(id) : id;
};
ssharing.isArray = function (arry) {
    return arry &&
            Object.prototype.toString.call(arry) == "[object Array]" &&
            typeof arry[0] !== "undefined";
};
ssharing.isFunction = function (fn) {
    return fn && Object.prototype.toString.call(fn) == "[object Function]";
}
ssharing.copy = function (op, opts) {
    for (var p in op) {
        if (p && !(p in opts)) {
            opts[p] = op[p];
        }
    }
}
ssharing.cover = function (op, opts) {
    for (var p in op) {
        if (p && (p in opts)) {
            opts[p] = op[p];
        }
    }
}
ssharing.extend = function (a, b) {
    for (var c in b) {
        a[c] = b[c];
    }
}
/*
override隐式转换为假则事件处理函数中的this为el本身
override全等true 则this为modify
this不全等 则this为override
*/
ssharing.addEvent = function (el, type, f, modify, override) {
    el = ssharing.getDom(el);
    var scope = (override && (override === true ? modify : override)) || el,
    fn = function (e) { return f.call(scope, e || window.event, el, modify) };
    if (window.attachEvent) {
        el.attachEvent("on" + type, fn);
    } else if (window.addEventListener) {
        el.addEventListener(type, fn, false);
    } else {
        el["on" + type] = fn;
    }
};
ssharing.removeEvent = function () {
    if (window.removeEventListener) {
        return function (el, sType, fn, capture) {
            el.removeEventListener(sType, fn, (capture));
        };
    } else if (window.detachEvent) {
        return function (el, sType, fn) {
            el.detachEvent("on" + sType, fn);
        };
    } else {
        return function () { };
    }
} ();
ssharing.getStyle = function (el, key) {
    el = ssharing.getDom(el);
    if (!el) return;
    if (window.getComputedStyle) {
        return window.getComputedStyle(el, null)[key];
    } else if (obj.currentStyle) {
        return obj.currentStyle[key];
    }
};
ssharing.each = function (obj, fn, scope) {
    var i = 0, len = obj.length, item;
    for (; i < len; i++) {
        item = obj[i];
        if (fn.apply(scope || item, [item, i]) === false) {
            break;
        }
    }
}
ssharing.hasClass = function (el, clsName) {
    el = ssharing.getDom(el);
    clsName = " " + clsName + " ";
    if ((" " + el.className + " ").indexOf(clsName) > -1) {
        return true;
    }
    return false;
};
ssharing.addClass = function (el, clsName) {
    el = ssharing.getDom(el);
    var b = false, setCls;
    if (el && clsName &&
	   !ssharing.hasClass(el, clsName)) {
        setCls = el.className;
        setCls += " " + clsName;
        el.className = ssharing.trim(setCls);
        b = true;
    }
    return b;
};
//将NodeList转换成Array
ssharing.nodeListToArray = function (nodes) {
    var arr, length;
    try {
        // works in every browser except IE
        arr = Array.prototype.slice.call(nodes);
        return arr;
    } catch (err) {
        // slower, but works in IE
        arr = [];
        length = nodes.length;

        for (var i = 0; i < length; i++) {
            arr.push(nodes[i]);
        }

        return arr;
    }
}
//继承
ssharing._extend = function (subc, superc, overrides) {
    if (!superc || !subc) {
        return;
    }
    var F = function () { }, i;
    F.prototype = superc.prototype;
    subc.prototype = new F();
    subc.prototype.constructor = subc;
    subc.superclass = superc.prototype;
    if (superc.prototype.constructor == Object.prototype.constructor) {
        superc.prototype.constructor = superc;
    }
    if (overrides) {
        for (i in overrides) {
            if (overrides.hasOwnProperty(i)) {
                subc.prototype[i] = overrides[i];
            }
        }
    }
}

//日历控件
ssharing.calendar = function (groups) {
    this.init.apply(this, arguments);
}
ssharing.calendar.prototype = {
    today: null, //今天的日期
    colums: 2, //显示月份数
    container: null, //日历容器(如不传入此参数则自动创建)
    containerId: null, //日历容器ID
    cells: null, //保存所有日期单元
    cellDates: null, //保存所有日期
    selectedDatesLength: null, //可选中日期个数
    selectedDates: null, //选中日期的相关数据([0]:日期,[1]:在cells中的索引)
    dateSeparator: '-', //日期分隔符
    input: null, //起始日期文本控件
    toinput: null, //结束日期文本控件（可选）
    hasInput: false, //是否传入起始日期控件
    hasToInput: false, //结束日期控件
    starDay: 0, //以星期几为一周的起始日(默认星期1)
    hideBlankWeeks: true, //显示或者隐藏不属于当前渲染日期月份的日期单元
    display_days: 42, //一页显示42个日期单元格
    prefix_dl_colums: "",
    prefix_c_title: "",
    prefix_iframe: "",
    useIframe: true,
    iframe: null,
    isShow: false, //日历显示状态
    containerWidth: 155, //日历默认宽度
    showForWho: null, //指定按哪个文本控件计算日历的显示位置
    monthType: "numbers",
    mindate: null,
    maxdate: null,
    freemode: false,
    strings: {//本地化配置参数
        prevText: "上个月",
        nextText: "下个月",
        weekDayName: ["日", "一", "二", "三", "四", "五", "六"],
        ymd: ["年", "月", "日"],
        month: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"]
    },
    addFocused: false,
    addFocusedStart: false,
    init: function (config) {
        this.selectedDatesLength = 1;
        this.selectedDates = [];
        this.cells = [];
        this.cellDates = [];
        this.today = new Date;
        this.initStyles();
        ssharing.cover(config, this);
        this.container = ssharing.getDom(this.containerId);
        this.input = ssharing.getDom(this.input);
        this.setToInput(this.toinput);
        this.initContainer();
        this.prefix_dl_colums = this.containerId + "_dl_colums";
        this.prefix_c_title = this.containerId + "c_title";
        this.prefix_iframe = this.containerId + "_iframe";
        this.mindate = this.mindate && this._parseDate(this.mindate);
        this.maxdate = this.maxdate && this._parseDate(this.maxdate);
        this.setPageDate(this.today);
        this.configIframe();
        this.initEvent();
    },
    configIframe: function () {
        var iframe, css = [];
        if (Dom.inDocument(this.container) && this.useIframe) {
            var pos = Dom.getStyle(this.container, "position");
            if (pos == "absolute" || pos == "relative") {
                if (!Dom.inDocument(iframe)) {
                    iframe = this.iframe = document.createElement("iframe");
                    iframe.id = this.prefix_iframe;
                    iframe.src = "javascript:false;";
                    iframe.tabIndex = -1;
                    css[css.length] = "opacity:0;filter:alpha(opacity=0);border:0;margin:0;padding:0;"
                    css[css.length] = "position:absolute;display:none;"
                    css[css.length] = "width:" + Dom.getStyle(this.container, "width") + ";";
                    css[css.length] = "height:" + Dom.getStyle(this.container, "height") + ";";
                    iframe.style.cssText = css.join('');
                    document.body.appendChild(iframe);
                }
            }
        }
        iframe = null;
    },
    checkInput: function () {
        this.hasInput = this.input ? true : false;
        this.hasToInput = this.toinput ? true : false;
    },
    setInput: function (input) {
        this.input = ssharing.getDom(input);
        this.checkInput();
        if (!this.addFocusedStart) {
            if (this.input) {
                Event.on(this.input, "focus", this.doInputFocus, this);
                this.addFocusedStart = true;
            }
        } else {
            if (this.input) {
                Event.removeListener(this.input, "focus", this.doInputFocus);
                this.addFocusedStart = false;
            }
        }
    },
    setToInput: function (toinput) {
        this.toinput = ssharing.getDom(toinput);
        this.checkInput();
        if (!this.addFocused) {
            if (this.toinput) {
                Event.on(this.toinput, "focus", this.doInputFocus, this);
                this.addFocused = true;
            }
        } else {
            if (this.toinput) {
                Event.removeListener(this.toinput, "focus", this.doInputFocus);
                this.addFocused = false;
            }
        }
    },
    initContainer: function () {
        if (!this.container) {
            var container = document.createElement("div");
            container.id = this.containerId = Dom.generateId(container, "ssharing_calendar");
            this.container = document.body.appendChild(container);
        }
    },
    initStyles: function () {
        //var defStyle = ssharing.calendar._STYLES;
        this.Style = {
            css_title: "c_title",
            css_title_prev: "prev",
            css_title_next: "next",
            css_columns: "c_columns",
            css_calendar: "ssharing_calendar",
            css_dl_container: "dl_container",
            css_holiday: "holiday",
            css_passed_day: "passed_day",
            css_today: "today",
            css_blank_day: "blank_day",
            css_a_selectable: "selectable"
        }
    },
    doPrev: function () {
        this.setPageDate(this.add(this.pagedate, "m", -1));
    },
    doNext: function () {
        this.setPageDate(this.add(this.pagedate, "m", 1));
    },
    doCellSelect: function (el) {
        var date;
        ssharing.each(this.cells, function (ele) {
            Dom.removeClass(ele, this.Style.css_a_selectable);
        }, this);
        date = this.select(el);
        ssharing.each(this.selectedDates, function (ele, index) {
            Dom.addClass(this.cells[ele[1]], this.Style.css_a_selectable);
        }, this);
        if (this.hasInput && this.hasToInput) {
            //var pattern = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
            if (this.showForWho == this.input /*&& !pattern.test(this.toinput.value)*/) {
                this.show(this.toinput);
            }
        }
        this.afterSelectFn(date);
    },
    doInputFocus: function (e, scope) {
        scope.show(this);
    },
    afterSelectFn: function (selectDates) { },
    initEvent: function () {
        if (this.hasInput) {
            Event.on(this.input, "focus", this.doInputFocus, this);
            this.addFocusedStart = true;
        }
        if (this.hasToInput) {
            Event.on(this.toinput, "focus", this.doInputFocus, this);
            this.addFocused = true;
        }
        Event.on(document, "click", function (e) {
            var el = Event.getTarget(e);
            var container = this.container;
            if (el != container && !Dom.isAncestor(container, el) && el != this.input && el != this.toinput) {
                this.hide();
            }
        }, true, this);
        Event.on(this.container, "click", function (e) {
            var me = this;
            this.findTarget(e, function (el, doWhat) {
                if (doWhat) {//翻页事件处理
                    doWhat.call(me);
                }
                else {//选中日期事件处理
                    me.doCellSelect(el);
                }
            }, "a");
            Event.stopEvent(e);
        }, true, this);
        Event.on(window, "resize", this.fixIEWindowEvent, { scope: this, name: "calendarResizeEnd", speed: 1 }, true);
        Event.on(window, "scroll", this.fixIEWindowEvent, { scope: this, name: "calendarScrollEnd", speed: 100 }, true);
    },
    select: function (el) {
        var index = el.getAttribute("_index"), date = this.cellDates[index];
        if (this.selectedDates.length == this.selectedDatesLength) {
            this.selectedDates.shift();
        }
        this.selectedDates.push([date, index]);
        this.showForWho.value = date;
        this.hide();
        return date;
    },
    findCells: function () {
        var tmp = [], itemDl, i = 0, el, alist;
        while (el = ssharing.getDom(this.prefix_dl_colums + i++)) {
            alist = el.getElementsByTagName("a");
            tmp = tmp.concat(ssharing.nodeListToArray(alist));
        }
        //        for (var i = 0; i < this.colums; i++) {
        //            tmp = tmp.concat(ssharing.getDom(this.prefix_dl_colums + i).getElementsByTagName("a"));
        //        }
        return tmp;
    },
    findTarget: function (e, fn, tagName) {
        var target = e ? target = Event.getTarget(e) : this;
        tagName = tagName || "li";
        var isPrev = ssharing.hasClass(target, this.Style.css_title_prev),
            isNext = ssharing.hasClass(target, this.Style.css_title_next),
            type;
        while (target.tagName && target.tagName.toLowerCase() != tagName) {
            target = target.parentNode;
            if (!target.tagName || target.tagName.toLowerCase() == "html") {
                return;
            }
        }
        if (ssharing.hasClass(target, this.Style.css_blank_day) || (!this.freemode && ssharing.hasClass(target, this.Style.css_passed_day))) {
            return;
        }
        if (isPrev || isNext) {//上一页或者下一页
            if (isPrev) {
                type = this.doPrev;
            } if (isNext) {
                type = this.doNext;
            }
        }
        fn(target, type);
    },
    setPageDate: function (newDate) {
        this.pagedate = this._parseDate(newDate);
        this.cellDates.length = 0; //清空日历列表中的所有日历
        this.createHtml();
    },
    fixIEWindowEvent: function () {
        var self = this;
        if (YAHOO.env.ua.ie > 0) {//保证IE只执行一次
            if (!window[this.name]) {
                window[this.name] = -1;
            }

            clearTimeout(window[this.name]);

            window[this.name] = setTimeout(function () {
                if (self.scope.isShow) {
                    self.scope.show(self.scope.showForWho);
                }
            }, this.speed);
        } else {
            if (this.scope.isShow) {
                this.scope.show(this.showForWho);
            }
        }
    },
    fixPos: function (target, container) {
        var containerOW = container.offsetWidth,
            containerOH = container.offsetHeight,
            targetOW = target.offsetWidth,
            targetOH = target.offsetHeight,
            body = document.body, de = document.documentElement,
            bodyWidth = Math.max(body.offsetWidth, de.offsetWidth),
            bodyHeight = Math.max(body.clientHeight, de.clientHeight),
            targetXY = Dom.getXY(target);
        var needChangeX = targetXY[0] + containerOW > bodyWidth,
            needChangeY = targetXY[1] + containerOH > bodyHeight;
        var left = needChangeX ? targetXY[0] + targetOW - containerOW : targetXY[0],
            top = needChangeY ? targetXY[1] - containerOH : targetXY[1] + targetOH;
        return [left, top];
    },
    show: function (toinput) {
        //        if (this.hasInput && this.input.value) {
        //            this.setPageDate(this.input.value);
        //        }
        var me = this;
        //setTimeout(function () {
        me.showForWho = toinput || me.input;
        Dom.setStyle(me.container, "display", "block");
        var xy = me.fixPos(me.showForWho, me.container);
        Dom.setXY(me.container, xy);
        me.isShow = me;

        if (me.useIframe) {
            Dom.setStyle(me.iframe, "display", "block");
            Dom.setXY(me.iframe, xy);
        }
        //}, 20);
    },
    hide: function () {
        //Dom.insertBefore(document.body, document.createTextNode(this.containerId + "\r\n"));
        Dom.setStyle(this.container, "display", "none");
        this.isShow = false;
        if (this.useIframe) {
            Dom.setStyle(this.iframe, "display", "none");
        }
    },
    _parseDate: function (dateString) {
        var date = Object.prototype.toString.call(dateString) === "[object Date]" ? dateString
                    : (ssharing.isArray(dateString) ? dateString : dateString.split(this.dateSeparator));
        if (date.length === 3) {
            date = new Date(date[0], parseInt(date[1]) - 1, date[2]);
        }
        return date;
    },
    _getLocalDate: function (date, _delete) {
        var k = [date.getFullYear(), date.getMonth(), date.getDate()];
        var dateArray = [date.getFullYear(), date.getMonth() + 1, date.getDate()];
        _delete && dateArray.splice(_delete, 1);
        return dateArray.join(this.dateSeparator);
    },
    getMonthByNum: function (date, num) {
        var d = new Date(date.getTime());
        d.setDate(1);
        return this.add(d, "m", num);
    },
    clearTime: function (date) {
        date.setHours(12, 0, 0, 0);
        return date;
    },
    add: function (date, field, amount) {
        var d = new Date(date.getTime());
        switch (field.toLowerCase()) {
            case "m":
                var newMonth = date.getMonth() + amount;
                var years = 0;

                if (newMonth < 0) {
                    while (newMonth < 0) {
                        newMonth += 12;
                        years -= 1;
                    }
                } else if (newMonth > 11) {
                    while (newMonth > 11) {
                        newMonth -= 12;
                        years += 1;
                    }
                }
                d.setMonth(newMonth);
                d.setFullYear(date.getFullYear() + years);
                break;
            case "d":
                //this._addDays(d, amount);
                d.setDate(date.getDate() + amount);
                break;
            case "y":
                d.setFullYear(date.getFullYear() + amount);
                break;
            case "w":
                //this._addDays(d, (amount * 7));
                d.setDate(date.getDate() + (amount * 7));
                break;
        }
        return d;
    },
    headHtml: function (html, text, clsName) {
        html[html.length] = '<a href="#" class="' + clsName + '">' + text + '</a>';
    },
    renderHeader: function (html, index, pagedate) {
        var style = this.Style,
        strings = this.strings,
        prev = !!(index == 0),
        next = !!(index == (this.colums - 1)),
        text, clsName;

        html[html.length] = '<div class="' + this.Style.css_title + '" id="' + (this.prefix_c_title + index) + '">';
        if (prev) {
            text = strings.prevText;
            clsName = style.css_title_prev;
            this.headHtml(html, text, clsName);
        } if (next) {
            text = strings.nextText;
            clsName = style.css_title_next;
            this.headHtml(html, text, clsName);
        }
        html[html.length] = this.buildMonthLabel(pagedate);
        html[html.length] = '</div>';
        return html;
    },
    getMonthType: function (date) {
        if (this.monthType == "CNnumbers") {
            return this.strings.month[date.getMonth()];
        }
        return date.getMonth() + 1;
    },
    buildMonthLabel: function (date) {
        var kk = date.getMonth();
        var monthLabel = this.getMonthType(date) + this.strings.ymd[1],
			yearLabel = date.getFullYear() + this.strings.ymd[0];
        return '<label>' + yearLabel + monthLabel + '</label>';
    },
    renderBody: function (html) {
        var count = this.colums;
        for (var i = 0; i < count; i++) {
            html = this.contentHtml(html, i, this.getMonthByNum(this.pagedate, i));
        }
        return html;
    },
    contentHtml: function (html, index, pagedate) {
        var star,
        end, //当前日期的下一个月
        preDays, //当前日期的上一个月有多少天显示在当前月的日历中
        monthDays, //当前月又多少天
        nextDays, //当前日期的下一个月有多少天显示在当前月的日历中
        startDay = this.starDay, //一周以星期几开始(默认周日)
        workingDate = pagedate, //当前渲染所用的日期(简称当前日期)
        kkk = workingDate.getMonth(),
        yearAndMonth = this._getLocalDate(workingDate, 2).split(this.dateSeparator);

        yearAndMonth.push("1");
        star = this._parseDate(yearAndMonth); //设置为当前日期的第一天

        var preDays = star.getDay(),
        today = this.today,
        todayYear = today.getFullYear(),
        todayMonth = today.getMonth(),
        todayDay = today.getDate(),
        style = this.Style,
        mindate = this.mindate,
        maxdate = this.maxdate;
        //如果一周以指定星期几开始显示.则相应调整位置
        if (startDay > 0) {
            this.preMonthDays -= startDay;
        }
        if (this.preMonthDays < 0) {
            this.preMonthDays += 7;
        }

        end = this.add(workingDate, "m", 1); //获得当前月的下一个月Date对象
        end.setDate(1); //设置为当前月个月的第一天

        d = new Date(end.getTime());
        d.setDate(d.getDate() - 1); //获取当前月的最后一天

        monthDays = d.getDate();
        nextDays = this.display_days - preDays - monthDays; //默认显示日期数 - 上个月显示在这个月的天数 - 这个月总天数 = 下个月显示在这个月的天数

        workingDate = this.add(star, "d", (preDays * -1));
        this.clearTime(workingDate);

        if (this.hideBlankWeeks && nextDays >= 7) {
            var blankWeeks = Math.floor(nextDays / 7);
            for (var p = 0; p < blankWeeks; ++p) {
                nextDays -= 7;
            }
        }
        var preCount = preDays;
        html[html.length] = '<div class="' + style.css_columns + '">';
        this.renderHeader(html, index, pagedate);
        html[html.length] = '<dl class="' + style.css_dl_container + '" id="' + (this.prefix_dl_colums + index) + '">';
        for (var d = 0; d < 7; d++) {
            if (d % 7 == 0 || (d + 1) % 7 == 0) {
                html[html.length] = "<dt class='" + style.css_holiday + "'>" + this.strings.weekDayName[d] + "</dt>";
            } else {
                html[html.length] = "<dt>" + this.strings.weekDayName[d] + "</dt>";
            }
        }

        html[html.length] = "<dd>";
        for (var i = 0, count = 0; i < 6; i++) {
            if (i !== 0 && this.hideBlankWeeks === true && workingDate.getMonth() != pagedate.getMonth()) {//下个月日期大于7天的多余天数不显示
                break;
            } else {
                for (var d = 0; d < 7; d++, preCount--) {
                    var h, wd = workingDate, css, range = false;

                    if (mindate === null) {
                        range = true;
                    } else {
                        this.clearTime(mindate);
                    }
                    if (maxdate === null) {
                        range = true;
                    } else {
                        this.clearTime(maxdate);
                    }
                    //如果配置了日期范围则该日期范围之外的日期不选
                    if ((mindate && (workingDate.getTime() < mindate.getTime())) ||
						(maxdate && (workingDate.getTime() > maxdate.getTime()))
					) {
                        css = style.css_passed_day;
                        range = false;
                    } else {
                        range = true;
                        //this.renderCell(html, workingDate, style.css_passed_day);
                    }
                    if (range) {
                        if (workingDate.getMonth() != pagedate.getMonth()) {//不是当前渲染所用日期月份的日期单元
                            //html[html.length] = "<a href='#' class='" + style.css_blank_day + "'></a>";
                            //this.renderCell(html, null, style.css_blank_day);
                            wd = null;
                            css = style.css_blank_day;
                        }
                        else if (workingDate.getFullYear() == todayYear &&
                                workingDate.getMonth() == todayMonth &&
                                workingDate.getDate() == todayDay
                    ) {//今天
                            //this.renderCell(html, workingDate, style.css_today);
                            css = style.css_today;
                        } else if (workingDate < this.today && !this.freemode) {//小于今天的日期
                            //this.renderCell(html, workingDate, style.css_passed_day);

                            css = style.css_passed_day;
                        } else if (count % 7 == 0 || (count + 1) % 7 == 0) {//休息日
                            //this.renderCell(html, workingDate, style.css_holiday);

                            css = style.css_holiday;
                        }
                        else {//普通日期单元
                            var flag = false;
                            for (var s = 0; s < this.selectedDates.length; s++) {
                                var item = this.selectedDates[s];
                                var render = item[0].split(this.dateSeparator);
                                if (workingDate.getFullYear() == render[0] && (workingDate.getMonth() + 1) == render[1] && workingDate.getDate() == render[2]) {
                                    item[1] = count; //修正之前选中日期在新日期列表中的索引
                                    //this.renderCell(html, workingDate, style.css_a_selectable);
                                    css = style.css_a_selectable;
                                    flag = true;
                                }
                            }
                            if (!flag) {
                                //this.renderCell(html, workingDate);
                                css = undefined;
                            }
                        }
                    }

                    if (preCount > 0) {
                        //上个月的日期单元
                    }
                    if (count >= ((preDays + monthDays + nextDays) - 7)) {
                        //下个月的日期单元
                    }
                    this.renderCell(html, wd, css);
                    var workingArray = this._getLocalDate(workingDate);
                    this.cellDates[this.cellDates.length] = workingArray;
                    workingDate = this.add(workingDate, "d", 1);
                    count++;
                }
            }
        }
        html[html.length] = "</dd>";
        html[html.length] = "</dl>";
        html[html.length] = "</div>";
        return html;
    },
    renderCell: function (html, workingDate, clsName) {
        var day = (workingDate && workingDate.getDate()) || "";
        if (!!clsName) {
            html[html.length] = "<a _index=" + this.cellDates.length + " class='" + clsName + "'>" + day + "</a>";
        } else {
            html[html.length] = "<a _index=" + this.cellDates.length + ">" + day + "</a>";
        }
    },
    createHtml: function () {
        var html = [];
        ssharing.addClass(this.container, this.Style.css_calendar);
        Dom.setStyle(this.container, "width", (this.containerWidth * this.colums) + "px");
        html = this.renderBody(html);
        this.container.innerHTML = html.join('\n');
        this.cells = this.findCells();

    }
}
/*ssharing.calendar end*/
/*table:ID，oddcls,奇数行样式,evenCls:偶数行样式,是否包含th 默认不包含，*/
ssharing.tableOdd_Even = function (table, oddCls, evenCls, containTh) {
    table = ssharing.getDom(table);
    oddCls = oddCls || "trodd";
    evenCls = evenCls || "treven";
    var len = table.rows.length,
        i = containTh === true ? 0 : 1,
        j = 0;
    for (; i < len; i++, j++) {
        ssharing.addClass(table.rows[i], j % 2 == 0 ? oddCls : evenCls);
    }
};
 
ssharing.tableIdOdd_Even =  function (table, attr,oddCls, evenCls) {
	table = ssharing.getDom(table);
    oddCls = oddCls || "trodd";
    evenCls = evenCls || "treven";
    var len = table.getElementsByTagName(attr).length;
	//alert(len);
	for (var i=0; i < len; i++) {
        ssharing.addClass(table.getElementsByTagName(attr)[i], i % 2 == 0 ? oddCls : evenCls);
    }
};

//文本框默认值交互 el:文本框ID，text：文本框默认值,color:文本框正常颜色,defaultColor:文本框默认颜色
ssharing.hint = function (el, text, color, defaultColor) {
    el = ssharing.getDom(el);
    if (!el) return;
    if (arguments.length < 2) return;
    color = color || "black";
    defaultColor = defaultColor || "#999";
    if (!el.value) {
        el.value = text;
    }
    if (el.value == text) {
        el.style.color = defaultColor;
    }
    Event.on(el, "focus", function () {
        if (text == this.value) {
            this.value = "";
            this.style.color = color;
        }
    }, el, true);
    Event.on(el, "blur", function () {
        if (text == this.value || "" == this.value) {
            this.value = text;
            this.style.color = defaultColor;
        }
    }, el, true);
};
//判断浏览器中是否安装了flash插件
ssharing.isInstalledFlash = function () {
    var installed = false,
        version = 0, words, plugin, numTypes, swf;
    //只有IE 的navigator.plugins.length为0.
    if (navigator.plugins &&
        navigator.plugins.length > 0 &&
        navigator.plugins["Shockwave Flash"]) {
        words = navigator.plugins["Shockwave Flash"].description.split(" ");
        for (var i = 0; i < words.length; ++i) {
            if (!isNaN(parseInt(words[i]))) {
                version = parseInt(words[i]);
            }
        }
        if (version >= 5) {
            plugin = navigator.plugins["Shockwave Flash"];
            numTypes = plugin.length;
            for (j = 0; j < numTypes; j++) {
                mimetype = plugin[j];
                if (mimetype &&
                    mimetype.enabledPlugin &&
                    mimetype.suffixes.indexOf("swf") != -1 &&
                    navigator.mimeTypes["application/x-shockwave-flash"] != null) {
                    installed = true;
                }
            }
        }
    }
    if (navigator.plugins && navigator.plugins.length === 0) {
        try {
            swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
            words = swf.GetVariable("$version");
            version = parseInt(words.split(" ")[1].split(",")[0]);
            if (version >= 5) {
                installed = true;
            }
        }
        catch (D) {
            installed = false;
        }
    }
    return { installed: installed, version: version };
};

/*
acModule2OtherModule
我的商旅-个人信息-偏好 交互操作
*/
ssharing.acModule2OtherModule = function (options) {
    this.selected = {};
    this.aCache = null;
    this.maxCacheCount = 5;
    this._nDelayID = -1;
    this.queryDelay = 0.2;
    this.ctlIsDown = false;
    this.shiftDown = false;
    this.twiceWithShift = new Array(2);
    this.conn = YAHOO.util.Connect;
    if (options.container) {
        this.container = ssharing.getDom(options.container);
        this.input = this.container.getElementsByTagName("input")[0];
        this.ulist = this.container.getElementsByTagName("ul")[0];
        if (this.ulist && this.input && this.input.type == "text") { }
        else { return };
    } else {
        return;
    }
    ssharing.copy(options, this);
    this.init();
    this.initEvent();
};
//为查询添加缓存
ssharing.acModule2OtherModule.prototype.addToCache = function (oRequest, oResponse) {
    var aCache = this.aCache, nCacheLength = aCache.length;
    if (!aCache) {
        return;
    }
    for (var i = nCacheLength - 1; i >= 0; i--) {
        var oCacheElem = aCache[i];
        if (oRequest === oCacheElem.request) {
            return;
        }
    }
    while (aCache.length >= this.maxCacheCount) {
        aCache.shift();
    }
    var oCacheElem = { request: oRequest, response: oResponse };
    aCache[aCache.length] = oCacheElem;
};
//获取缓存
ssharing.acModule2OtherModule.prototype.getCache = function (oRequest) {
    var aCache = this.aCache;
    if (this.maxCacheCount > 0) {
        if (!aCache) {
            this.aCache = [];
        }
        else {
            var nCacheLength = aCache.length;
            if (nCacheLength > 0) {
                var oResponse = null;
                for (var i = nCacheLength - 1; i >= 0; i--) {
                    var oCacheElem = aCache[i];
                    if (oRequest === oCacheElem.request) {
                        oResponse = oCacheElem.response;
                        if (i < nCacheLength - 1) {
                            aCache.splice(i, 1);
                            this.addToCache(oRequest, oResponse);
                        }
                        oResponse.cached = true;
                        break;
                    }
                }
                return oResponse;
            }
        }
    }
    else if (aCache) {
        this.aCache = null;
    }
    return null;
};
//发送请求
ssharing.acModule2OtherModule.prototype.sendQuery = function (sQuery) {
    var self = this, oResponse;
    if (this._nDelayID != -1) {
        clearTimeout(this._nDelayID);
    }
    sQuery = encodeURIComponent(sQuery);
    this._nDelayID = -1;
    oResponse = this.getCache(sQuery);
    if (oResponse) {
        self.response(oResponse);
    } else {
        this.conn.asyncRequest("GET", this.seturi(sQuery), {
            success: function (oResponse) { self.response(oResponse) },
            failure: function (oResponse) { self.response(oResponse) },
            argument: {
                query: sQuery
            }
        })
    }
};

ssharing.acModule2OtherModule.prototype.response = function (oResponse) {
    if (oResponse.argument) {
        this.addToCache(oResponse.argument.query, oResponse);
    }
    this.initList(YAHOO.lang.JSON.parse(oResponse.responseText));
};
ssharing.acModule2OtherModule.prototype.pushSelected = function (data, index) {
    this.selected[data.V] = { data: data, index: index };
};
ssharing.acModule2OtherModule.prototype.popSelected = function (property) {
    delete this.selected[property];
};
ssharing.acModule2OtherModule.prototype.getSelected = function () {
    return this.selected;
};
//屏蔽无效键盘按键
ssharing.acModule2OtherModule.prototype._isIgnoreKey = function (nKeyCode) {
    if ((nKeyCode == 9) || (nKeyCode == 13) || // tab, enter
            (nKeyCode == 16) || (nKeyCode == 17) || // shift, ctl
            (nKeyCode >= 18 && nKeyCode <= 20) || // alt, pause/break,caps lock
            (nKeyCode == 27) || // esc
            (nKeyCode >= 33 && nKeyCode <= 35) || // page up,page down,end
    /*(nKeyCode >= 36 && nKeyCode <= 38) || // home,left,up
    (nKeyCode == 40) || // down*/
            (nKeyCode >= 36 && nKeyCode <= 40) || // home,left,up, right, down
            (nKeyCode >= 44 && nKeyCode <= 45) || // print screen,insert
            (nKeyCode == 229) // Bug 2041973: Korean XP fires 2 keyup events, the key and 229
        ) {
        return true;
    }
    return false;
};
ssharing.acModule2OtherModule.prototype.onTextboxKeyUp = function (v, oSelf) {
    var sText = this.value;
    var nKeyCode = v.keyCode;
    if (oSelf._isIgnoreKey(nKeyCode)) {
        return;
    }
    if (oSelf._nDelayID != -1) {
        clearTimeout(oSelf._nDelayID);
    }
    oSelf._nDelayID = setTimeout(function () {
        oSelf.sendQuery(sText);
    }, (oSelf.queryDelay * 1000));
};
//双击添加
ssharing.acModule2OtherModule.prototype._doubleClick = function (e) {
    var self = this;
    this.findTarget(e, function (t) {
        if (t) {
            var data = self.data[t.itemIndex];
            self.toTextArea(data);
            self.pushSelected(data, t.itemIndex);
        }
    });
};
ssharing.acModule2OtherModule.prototype.getElSelected2TextArea = function () {
    var self = this;
    ssharing.each(this.ulist.getElementsByTagName("li"), function (item, index) {
        if (ssharing.hasClass(item, "selected")) {
            var data = self.data[item.itemIndex];
            self.toTextArea(data);
            self.pushSelected(data, item.itemIndex);
        }
    });
};
ssharing.acModule2OtherModule.prototype.removeTextAreaSelected = function () {
    if (!this.textArea) {
        return;
    }
    var textArea = ssharing.getDom(this.textArea);
    if (textArea.selectedIndex == -1) {
        return;
    }
    var selectItem = textArea.options[textArea.selectedIndex];
    selectItem.parentNode.removeChild(selectItem);
    this.popSelected(selectItem.value);
    this.removeTextAreaSelected();
};
ssharing.acModule2OtherModule.prototype.toTextArea = function (dsItem) {
    if (!this.textArea) {
        return;
    }
    if (!this.getSelected().hasOwnProperty(dsItem.V)) {
        var textArea = ssharing.getDom(this.textArea);
        //<option value="NS">东北航空公司</option>
        var option = document.createElement("option");
        option.value = dsItem.V;
        option.innerHTML = dsItem.C;
        textArea.appendChild(option);
    }
};
ssharing.acModule2OtherModule.prototype.seturi = function (query) {
    return this.url + this.params + (query || "");
};
ssharing.acModule2OtherModule.prototype.init = function () {
    var self = this;
    ssharing.hint(this.input, "请输入关键字查询");
    if (this.defaultData) {
        this.initList(this.defaultData);
    } else {
        this.conn.asyncRequest("GET", this.seturi(), {
            success: function (oResponse) { self.response(oResponse) },
            failure: function (oResponse) { self.response(oResponse) },
            cache: true
        })
    }
};
ssharing.acModule2OtherModule.prototype.initList = function (data) {
    var len = data.length,
        list = this.ulist,
        fragment = document.createDocumentFragment,
        item;
    this.data = data;
    this.clearList();
    while (list.childNodes.length < len) {
        item = document.createElement("li");
        item.innerHTML = data[list.childNodes.length].C;
        item.itemIndex = list.childNodes.length;
        list.appendChild(item);
    }
};
ssharing.acModule2OtherModule.prototype.findTarget = function (e, fn, tagName) {
    var target = e ? target = Event.getTarget(e) : this;
    tagName = tagName || "li";
    while (target.tagName && target.tagName.toLowerCase() != tagName) {
        target = target.parentNode;
        if (!target.tagName || target.tagName.toLowerCase() == "html") {
            return;
        }
    }
    fn(target, e);
};
ssharing.acModule2OtherModule.prototype.keyCodeState = function (ev, value) {
    return ev.keyCode == value;
}
//设置twiceWithShift[0]到twiceWithShift[1]区间的元素选中
ssharing.acModule2OtherModule.prototype.forShiftSelect = function (target) {
    var one = this.twiceWithShift[0], two = this.twiceWithShift[1];
    if (typeof one === 'number' && isFinite(one)) {
        two = target.itemIndex;
        var tmp = 0;
        if (one > two) {
            tmp = one;
            one = two;
            two = tmp;
        }
        for (var i = one; i <= two; i++) {
            ssharing.addClass(this.ulist.getElementsByTagName("li")[i], "selected");
        }
    }

}
ssharing.acModule2OtherModule.prototype.initEvent = function () {
    var self = this;
    Event.on(this.input, "keyup", this.onTextboxKeyUp, self);
    //禁止UL内的文字被选中，解决双击,ctl,shift会选中文字的情况
    this.ulist.style.cssText = "-moz-user-select:none";
    this.ulist.onselectstart = function () { return false; };
    Event.on(this.ulist, "select", function () {
        document.selection && document.selection.empty();
        window.getSelection && window.getSelection().removeAllRanges();
    });
    Event.on(this.ulist, "dblclick", this._doubleClick, this, true);
    Event.on(document, "keydown", function (e) {
        if (this.keyCodeState(e, 17)) {//ctl
            this.ctlIsDown = true;
        }
        if (this.keyCodeState(e, 16)) {//shift
            this.shiftDown = true;
        }
    }, this, true);
    Event.on(document, "keyup", function (e) {
        if (this.keyCodeState(e, 17)) {//ctl
            this.ctlIsDown = false;
        }
        if (this.keyCodeState(e, 16)) {//shift
            this.shiftDown = false;
        }
    }, this, true);
    Event.on(this.ulist, "click", function (e) {
        this.findTarget(e, function (t, ev) {
            if (t) {
                if (!self.ctlIsDown) {
                    ssharing.each(self.ulist.getElementsByTagName("li"), function (item, index) {
                        Dom.removeClass(item, "selected");
                    });
                }
                if (self.shiftDown) {
                    self.forShiftSelect(t);
                    return;
                }
                //记录每次单击的元素index以备作为下次按住shift的单击时的起点元素index
                self.twiceWithShift[0] = t.itemIndex;
                ssharing.addClass(t, "selected");
            }
        });
    }, this, true);
    Event.on(this.ulist, "mouseover", function (e) {
        this.findTarget(e, function (t) {
            if (t) {
                ssharing.addClass(t, "highlight");
            }
        });
    }, this, true);
    Event.on(this.ulist, "mouseout", function (e) {
        this.findTarget(e, function (t) {
            if (t) {
                Dom.removeClass(t, "highlight");
            }
        });
    }, this, true);
    Event.on(this.textArea, "dblclick", function (e) {
        this.removeTextAreaSelected();
    }, this, true);
};
ssharing.acModule2OtherModule.prototype.clearList = function () {
    this.ulist.innerHTML = "";
};

//继承newTipBox 改写提示层内部HTML结构与样式
var tipBoxForTabel = function (Optinos) {
    tipBoxForTabel.superclass.constructor.call(this, Optinos);
}
ssharing._extend(tipBoxForTabel, newTipBox, {
    containerCss: "msgbox-table",
    delay: 501,
    boxInit: function (content, width) {
        newTipBox.invokCount++;
        this.picbox = new YAHOO.widget.Overlay(newTipBox.OVERLAYNAME + newTipBox.invokCount, {
            visible: false,
            width: "auto", zIndex: 101,
            autofillheight: true
        });
        this.top = "top" + newTipBox.invokCount;
        width = !!this.scroll ? (width + 26) : width;
        width = YAHOO.lang.isUndefined(width) ? "" : width;
        var html = [];
        html[html.length] = '<div class="' + this.containerCss + '" style="width:' + width + 'px">';
        html[html.length] = '   <div id="' + this.top + '">';
        html[html.length] = '        <div class="msgbox-table-icon"></div>';
        html[html.length] = '   </div>';
        html[html.length] = '<div class="box_text">';
        html[html.length] = content;
        html[html.length] = '</div>';
        html[html.length] = '   <div class="msgbox-table-shadow" style="' + (this.scroll && this.height ? "overflow:auto;height:" + this.height + "px;" : 'width:' + width + 'px') + '">';
        html[html.length] = '   </div>';
        html[html.length] = '</div>';
        this.picbox.setBody(html.join(''));
        this.picbox.render(document.body);
        Dom.setStyle(this.picbox.id, "position", "absolute");
        Dom.setStyle(this.picbox.id, "visibilty", "hidden");
    }
})
//差旅政策右下方提示层相关JS

Event.onDOMReady(function () {
    //设置用户交互事件
    var guideHandleZomm = Dom.get("guideHandleZomm"),
                userGuidContent = Dom.get("ctl00_ContentMain_userGuidContent"),
                GUIDPANEL = "guidPanel",
                guidPanel = Dom.get("ctl00_ContentMain_userGuid");
    if (guideHandleZomm && userGuidContent) {
        Event.on(guideHandleZomm, "click", function () {
            if (Dom.hasClass(userGuidContent, "dn")) {
                Dom.replaceClass(guideHandleZomm, "guide-container-big", "guide-container-small");
                Dom.removeClass(userGuidContent, "dn");
            } else {
                Dom.replaceClass(guideHandleZomm, "guide-container-small", "guide-container-big");
                Dom.addClass(userGuidContent, "dn");
            }
        });
        Event.on("guideHandleDisplay", "click", function () {
            Dom.addClass(guidPanel, "dn");
        })
        //IE7以下浏览器 不支持position:fixed时的代替方案.
        var flag = 0, anim, cHeight, runStatus = null
        , getTargetTop = function () {
            return Dom.getDocumentScrollTop() + Dom.getViewportHeight() - guidPanel.offsetHeight;
        },
        fixGuidPos = function () {
            if (runStatus) {
                clearTimeout(runStatus);
            }
            runStatus = setTimeout(function () {
                if (YAHOO.util.Anim) {
                    anim.attributes.top.to = getTargetTop();
                    anim.animate();
                } else {
                    Dom.setStyle(guidPanel, "top", getTargetTop() + "px");
                }
            }, 100);
        };
        if (YAHOO.env.ua.ie > 0 && YAHOO.env.ua.ie < 7) {
            cHeight = getTargetTop();
            Dom.setStyle(guidPanel, "top", cHeight + "px");
            if (YAHOO.util.Anim) {
                Dom.setStyle(guidPanel, "position", "absolute");
                anim = new YAHOO.util.Anim(guidPanel, { top: { from: cHeight} }, 1, YAHOO.util.Easing.easeOut);
                anim.onComplete.subscribe(function () {
                    this.attributes.top.from = this.attributes.top.to;
                })
            }
            Event.on(window, "resize", fixGuidPos);
            Event.on(window, "scroll", fixGuidPos);
        }
    }
})

//修正cloneNode 时 select内option元素selected属性丢失的情况
function _IEOptionLostSelected(selSource, selClone) {
    if (selSource && selClone) {
        selClone.options[selSource.selectedIndex].selected = true;
    }
}
function tableRender(id) {
    ssharing.tableOdd_Even(id);
    TableThrough.init(id);
}

//图形版首页 拖拽效果

var Y = YAHOO, Dom = Y.util.Dom, Event = Y.util.Event;
Y.namespace("SSharing");
Y.SSharing.DDList = function (id, sGroup, config) {
    Y.SSharing.DDList.superclass.constructor.call(this, id, sGroup, config);
    YAHOO.util.DDM.mode = 0; //设置为point模式
    this.targetProxyElId = "ygddtdiv";
    this.createTargetFrame();
    this.saveXY = [];
    this.target = "";
    this.checkSelf = null;
    this.isSwap = false;
}
if (Y.util.DDProxy) {
    Y.extend(Y.SSharing.DDList, Y.util.DDProxy, {
        getTargetProxyEl: function () {//
            return Dom.get(this.targetProxyElId);
        },
        createTargetFrame: function () {
            var self = this, body = document.body;

            if (!body || !body.firstChild) {
                setTimeout(function () { self.createTargetFrame(); }, 50);
                return;
            }

            var div = this.getTargetProxyEl(), Dom = YAHOO.util.Dom;

            if (!div) {
                div = document.createElement("div");
                div.id = this.targetProxyElId;
                var s = div.style;

                s.position = "absolute";
                s.visibility = "hidden";
                s.cursor = "move";
                s.border = "";
                s.zIndex = 999;
                s.height = "25px";
                s.width = "25px";

                var _data = document.createElement('div');
                Dom.setStyle(_data, 'height', '100%');
                Dom.setStyle(_data, 'width', '100%');
                /**
                * 如果代理元素没有背景色，IE 浏览器下就会被认为是透明的。因为它是透明的，所以事件将会穿过它而影响到下边的 iframe。所以需要创建一个“伪”元素在代理之上，并且给它一个背景色，然后给它的透明度设置为0，它实际上不在那里，但是 IE 仍然会认为它在，所以事件将不会继续传递。
                */
                Dom.setStyle(_data, 'background-color', '#ccc');
                Dom.setStyle(_data, 'opacity', '0');
                div.appendChild(_data);

                // 如果再文档加载完之前执行，在 IE 下 appendChild 将会失效，可能会有一些其它场景导致这种事情的发生。
                body.insertBefore(div, body.firstChild);
            }
        },
        /**
        * 覆盖了其父类initFrame方法
        * 为了保持代理元素与源元素一致,去除YUI创建的代理元素默认的边框
        */
        initFrame: function () {
            var div;
            this.createFrame();
            div = this.getDragEl();
            div.style.border = "";
        },
        /**
        * 当拖拽的像素阙值或者鼠标按下时的时间阙值时激活，默认的拖动阙值是鼠标移动3像素或者按下鼠标1秒钟
        * 保持代理元素与源元素一致,复制源元素的内容及样式,
        * 并且限制拖动范围为当前的显示区域，滚动条之外的除外
        */
        startDrag: function (x, y) {
            var offsetHeight,
                offsetWidth,
                viewPortWidth,
                viewPortHeight,
                scrollX,
                scrollY, nViewportOffset = 10;
            var dragEl = this.getDragEl();
            var clickEl = this.getEl();
            this.checkSelf = clickEl; //记录拖动的代理元素对应的实体元素
            this.isSwap = false;
            Dom.setStyle(clickEl, "visibility", "hidden");
            dragEl.innerHTML = clickEl.innerHTML;
            Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
            Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor"));

            offsetHeight = dragEl.offsetHeight;
            offsetWidth = dragEl.offsetWidth;

            viewPortWidth = Dom.getViewportWidth();
            viewPortHeight = Dom.getViewportHeight();

            scrollX = Dom.getDocumentScrollLeft();
            scrollY = Dom.getDocumentScrollTop();

            if (offsetHeight + nViewportOffset < viewPortHeight) {
                this.minY = scrollY + nViewportOffset;
                this.maxY = scrollY + viewPortHeight - offsetHeight - nViewportOffset;
            } else {
                this.minY = scrollY + nViewportOffset;
                this.maxY = scrollY + nViewportOffset;
            }

            if (offsetWidth + nViewportOffset < viewPortWidth) {
                this.minX = scrollX + nViewportOffset;
                this.maxX = scrollX + viewPortWidth - offsetWidth - nViewportOffset;
            } else {
                this.minX = scrollX + nViewportOffset;
                this.maxX = scrollX + nViewportOffset;
            }

            this.constrainX = true;
            this.constrainY = true;
        },
        onDragEnter: function (e, id) {

            var srcEl = this.getEl(); //拖动的代理元素对应的实体
            var destEl = Dom.get(id); //悬浮在该实体元素上
            if (destEl.nodeName.toLowerCase() == "li") {
                if (srcEl !== destEl) {//当前拖拽的代理元素不是从其对应的实体元素移出
                    this.showTargetProxyFrame(destEl.id);
                }
            }
            Y.util.DDM.refreshCache();
        },
        showTargetProxyFrame: function (id) {
            var targetEl = Dom.get(id); //悬浮在该实体元素上
            var targetProxyEl = this.getTargetProxyEl(); //目标元素代理

            this._resizeTargetProxy(id);
            this.setTargetProxyElPos(id);


        },
        /*
        *当一个拖拽对象悬浮在另一个拖拽对象上时则该对象的代理会自动的变成关联元素一样的大小，
        *除非 resizeFrame 被设置为 false，默认为true 该属性是继续自Y.util.DDProxy
        */
        _resizeTargetProxy: function (id) {
            if (this.resizeFrame) {
                var DOM = Y.util.Dom,
                    targetEl = Dom.get(id), //悬浮在该实体元素上
                    dragEl = this.getDragEl(),
                    targetProxyEl = this.getTargetProxyEl(),
                    newWidth, newHeight;

                var bt = parseInt(DOM.getStyle(targetEl, "borderTopWidth"), 10);
                var br = parseInt(DOM.getStyle(targetEl, "borderRightWidth"), 10);
                var bb = parseInt(DOM.getStyle(targetEl, "borderBottomWidth"), 10);
                var bl = parseInt(DOM.getStyle(targetEl, "borderLeftWidth"), 10);

                if (isNaN(bt)) { bt = 0; }
                if (isNaN(br)) { br = 0; }
                if (isNaN(bb)) { bb = 0; }
                if (isNaN(bl)) { bl = 0; }


                newWidth = Math.max(0, dragEl.offsetWidth - br - bl);
                newHeight = Math.max(0, dragEl.offsetHeight - bt - bb);


                DOM.setStyle(targetProxyEl, "width", newWidth + "px");
                DOM.setStyle(targetProxyEl, "height", newHeight + "px");
            }
        },
        /*
        *当拖拽元素悬浮到另外一个dragdrop上时 显示其对应的代理元素
        *并且缓动到当前top+10 left-10的位置
        */
        setTargetProxyElPos: function (id) {
            var targetEl = Dom.get(id), //悬浮在该实体元素上
                targetProxyEl = this.getTargetProxyEl(),
                xy = Dom.getXY(targetEl),
                self = this,
                a;

            targetProxyEl.innerHTML = targetEl.innerHTML;
            Dom.setStyle(targetProxyEl, "color", Dom.getStyle(targetEl, "color"));
            Dom.setStyle(targetProxyEl, "backgroundColor", Dom.getStyle(targetEl, "backgroundColor"));

            Dom.setStyle(targetEl, "visibility", "hidden");
            Dom.setStyle(targetProxyEl, "visibility", "");

            a = this.a = new Y.util.Motion(
                targetProxyEl, {
                    points: {
                        to: xy
                    }
                },
                0.2,
                YAHOO.util.Easing.easeOut
                )
            if (!this.a.isAnimated()) {
                Dom.setXY(targetProxyEl, xy);
                //移入的元素实体隐藏

                this.saveXY = xy.slice(0);
                this.target = id; //保存悬浮在某个实体元素上一遍移出时判断

                xy[0] = xy[0] + 10;
                xy[1] = xy[1] - 10;

                a.animate();
            }
        },
        /*
        *拖拽元素从另一个dropdrag元素移出时执行.
        */
        onDragOut: function (e, id) {
            var target = Dom.get(this.target), //移出前悬浮在哪个元素上
                self = this;
            if (Dom.get(this.checkSelf) !== target) {//当前拖拽的代理元素不是从其对应的实体元素移出

                Y.util.AnimMgr.stop(this.a);
                Dom.setStyle(self.getTargetProxyEl(), "visibility", "hidden");
                Dom.setStyle(target, "visibility", "");
            }
        },
        /*
        *这里 是移入了任何一个拖拽元素后停止并且松开鼠标后触发的事件
        *调用移位  目标代理层 从当前位置缓动到 拖拽实体位置后隐藏 交换 拖拽实体和目标实体.
        *同时 拖拽代理层从当前位置缓动移动到目标实体位置后隐藏 
        */
        onDragDrop: function (e, id) {
            var destEl = Dom.get(id),
                srcEl = this.getEl(),
                dragEl = this.getDragEl(),
                self = this,
                a, b;
            this.isSwap = true;
            a = new Y.util.Motion(
                this.getTargetProxyEl(), {
                    points: {
                        to: Dom.getXY(srcEl)
                    }
                },
                0.2,
                YAHOO.util.Easing.easeOut
                )

            a.onComplete.subscribe(function () {
                Dom.setStyle(self.getTargetProxyEl(), "visibility", "hidden");
                Dom.setStyle(srcEl, "visibility", "");
            });
            a.animate();

            b = new Y.util.Motion(
                dragEl, {
                    points: {
                        to: Dom.getXY(destEl)
                    }
                },
                0.2,
                YAHOO.util.Easing.easeOut
                )
            b.onComplete.subscribe(function () {
                Dom.setStyle(dragEl, "visibility", "hidden");
                Dom.setStyle(destEl, "visibility", "");
            });
            b.animate();

            Y.util.DDM.swapNode(srcEl, destEl);
        },
        /**
        * 当我们完成拖拽对象时激活此方法
        * 该方法会在onDragDrop 之后执行,所以需要区分.拖拽完成时,是否交换位置,如果交换过了.则不执行操作
        * 如果没交换,则拖拽元素则缓动回到原位
        */
        endDrag: function (e) {

            var srcEl = this.getEl(),
                proxy = this.getDragEl(),
                targetProxy = this.getTargetProxyEl();

            // Show the proxy element and animate it to the src element's location
            Dom.setStyle(proxy, "visibility", "");
            if (!this.isSwap) {
                var a = new Y.util.Motion(
                proxy, {
                    points: {
                        to: Dom.getXY(srcEl)
                    }
                },
                0.5,
                YAHOO.util.Easing.easeOut
                );
                var proxyid = proxy.id;
                var thisid = this.id;

                // Hide the proxy and show the source element when finished with the animation
                a.onComplete.subscribe(function () {
                    Dom.setStyle(proxyid, "visibility", "hidden");
                    Dom.setStyle(thisid, "visibility", "");
                });
                a.animate();
            }
        }
    })
}
Y.SSharing.DDApp = {
    init: function (list) {
        var ref, i;
        for (i = 0; i < list.length; i++) {
            ref = list[i];
            if (Dom.inDocument(ref)) {
                if (!Dom.hasClass(ref, "placeholderitem")) {
                    new Y.SSharing.DDList(ref);
                }
                new Y.util.DDTarget(ref);
                Y.SSharing.OrderManager.saveOldOrder(ref.id); //页面加载时保存服务器端的 排列顺序
            }
        }
    }
}
Y.SSharing.OrderManager = (function () {
    var isChanged = false, oldOrder = [], newOrder = [], urlParam = [],
            i, len, id, BLANK = "placeholderitem";
    return {
        /*
        *保存服务器端的 排列顺序
        */
        saveOldOrder: function (id) {
            oldOrder.push(id);
        },
        /*
        *判断用户是否拖动过
        */
        contrast: function () {
            len = oldOrder.length;
            for (i = 0; i < len; i += 1) {
                if (oldOrder[i] != newOrder[i]) {
                    return isChanged = true;
                }
            }
            return isChanged;
        },
        /*
        *用户拖动后的顺序保存，并且拼凑URL参数
        */
        saveNewOrder: function (list) {
            len = list.length;
            for (i = 0; i < len; i += 1) {
                if (!Dom.hasClass(list[i], BLANK)) {
                    id = list[i].id;
                    newOrder.push(id);
                    urlParam.push(id + "=" + i + "&");
                } else {
                    newOrder.push(BLANK);
                    urlParam.push(BLANK + "=" + i + "&");
                }
            }
        },
        sendRequest: function (method, url, sync, callback, postData) {

            var connObj = Y.util.Connect.getConnectionObject(),
                    param = urlParam.join(''),
                    uri = url + "?" + param.substring(0, param.length - 1);

            connObj.conn.open(method.toUpperCase(), uri, sync);

            connObj.conn.send(postData || '');

            if (connObj.conn && connObj.conn.readyState === 4) {
                YAHOO.util.Connect.handleTransactionResponse(connObj, callback);
            }
            return connObj;
        }
    }
})();
/*
*设置position为absolute的元素到目标元素的周围,
*提供8个位置 
tl: function () { },上方左对齐
tr: function () { },上方右对齐
bl: function () { },下方左对齐
br: function () { },下方右对齐
lt: function () { },左方上对齐
lb: function () { },左方下对齐
rt: function () { },右方上对齐
rb: function () { },右方下对齐
*/
Y.SSharing.Position = function (target, posObject) {
    var target = Dom.get(target),
        obj = Dom.get(posObject),
        targetW = target.offsetWidth,
        targetH = target.offsetHeight,
        objW = obj.offsetWidth,
        objH = obj.offsetHeight,
        x, y;

    function chnageXY() {
        var xy = Dom.getXY(target);
        x = xy[0];
        y = xy[1];
    }

    return {
        tl: function () {
            chnageXY();
            Dom.setXY(obj, [x, y - objH]);
            return [x, y - objH];
        },
        tr: function () {
            chnageXY();
            Dom.setXY(obj, [x + targetW - objW, y - objH]);
            return [x + targetW - objW, y - objH];
        },
        bl: function () {
            chnageXY();
            Dom.setXY(obj, [x, y + targetH]);
            return [x, y + targetH];
        },
        br: function () {
            chnageXY();
            Dom.setXY(obj, [x + targetW - objW, y + targetH]);
            return [x + targetW - objW, y + targetH];
        },
        lt: function () {
            chnageXY();
            Dom.setXY(obj, [x - objW, y]);
            return [x - objW, y];
        },
        lb: function () {
            chnageXY();
            Dom.setXY(obj, [x - objW, y + targetH - objH]);
            return [x - objW, y + targetH - objH];
        },
        rt: function () {
            chnageXY();
            Dom.setXY(obj, [x + targetW, y]);
            return [x + targetW, y];
        },
        rb: function () {
            chnageXY();
            Dom.setXY(obj, [x + targetW, y + targetH - objH]);
            return [x + targetW, y + targetH - objH];
        }
    }
}


YAHOO.namespace("SSharing");
//高铁动车 填写订单 配送信息地址使用到
YAHOO.SSharing.Area = function (config) {
    if (!config || !Y.util.Lang.isObject(config)) {
        return;
    }
    this.ULCLASSNAME = "address-ul";
    this.historyValue = "";
    this.container = null;
    this.provinceHistory = "";
    this.cityHistory = "";
    this.districtHistory = "";
    /*
    this.province = config.province;
    this.city = config.city;
    this.district = config.district;
    this.pcdText = config.pcdText;
    this.setData(config.data);
    */
    ssharing.copy(config, this);

    this.init();
}
YAHOO.SSharing.Area.prototype = {
    init: function (id) {
        this.createContainer(this.province);
        this.createContainer(this.city);
        this.createContainer(this.district);

        this.createHtml(this.province, this.data);

        this.initEvent(this.province);
    },
    /*
    * 创建包裹层
    */
    createContainer: function (forWho) {
        var container, body = document.body;
        container = document.createElement("div");
        container.className = "address-hot";
        container.style.cssText = "position:absolute;border:1px solid #67A1E2;box-shadow:2px 2px 5px #BBBBCC;display:none;font-size:12px";
        Dom.get(forWho.textBox).parentNode.appendChild(container);
        forWho.container = container;
    },
    /*
    * 文本框获得焦点事件
    */
    FocusHandle: function (ev, forWho) {
        Dom.setStyle(forWho.container, "display", "block");
        Y.SSharing.Position(forWho.textBox, forWho.container).bl();
    },
    /*
    * 根据ID 在数据源中深度查找匹配的数据
    */
    findDataById: function (id, data) {
        var temp, i, len, data, item;
        for (i = 0, len = data.length; i < len; i += 1) {
            temp = data[i];
            if (id == temp.id) {
                return temp;
            } else {
                if (temp.data) {
                    temp = arguments.callee(id, temp.data);
                    if (temp) {
                        return temp;
                    }
                }
            }
        }
    },
    provinceWorkContent: function (ev, matchEl) {
        this.provinceMouseDownHandle(ev, matchEl);
        this.fixHintCompliant(Dom.get(this.city.textBox));
    },
    /*
    * 省份列表mousedown事件处理函数
    * 根据选中的省查找数据以创建市列表并绑定事件
    * 会记录下最后一次选中的数据,以便下一次选中时比较,
    * 如与上一次选中的一样,则不会重新创建市列表,及更新详细地址.
    */
    provinceMouseDownHandle: function (ev, matchEl) {

        var data = this.setControlValue(matchEl, this.province, this.city),
                    city = Dom.get(this.city.textBox),
                    district = Dom.get(this.district.textBox);
        if (data.name != this.provinceHistory) {
            Dom.get(this.province.hideInput).value = data.id;
            Dom.get(this.province.textBox).value = data.name;
            this.createHtml(this.city, data.data);
            this.initEvent(this.city);
        } else {
        }

        this.provinceHistory = data.name;

        city.value = "";

        district.value = "";
        Dom.get(this.city.hideInput).value = "";
        Dom.get(this.district.hideInput).value = "";

        this.updatePcdText();
        this.createHtml(this.district, {});

        if (this.callBack && YAHOO.util.Lang.isFunction(this.callBack)) {
            this.callBack("province", data, matchEl);
        }
    },
    cityWorkContent: function (ev, matchEl) {
        this.cityMouseDownHandle(ev, matchEl);
        this.fixHintCompliant(Dom.get(this.district.textBox));
        this.fixValueColor(Dom.get(this.city.textBox));
    },
    /*
    * 市列表mousedown事件处理函数
    * 根据选中的市查找数据以创建区列表并绑定事件
    * 会记录下最后一次选中的数据,以便下一次选中时比较,
    * 如与上一次选中的一样,则不会重新创建区列表及更新详细地址.
    */
    cityMouseDownHandle: function (ev, matchEl) {

        var data = this.setControlValue(matchEl, this.city, this.district),
                    district = Dom.get(this.district.textBox),
                    city = Dom.get(this.city.textBox);

        if (data.name != this.cityHistory) {
            Dom.get(this.city.hideInput).value = data.id;
            city.value = data.name;
            this.createHtml(this.district, data.data);
        }

        this.cityHistroy = data.name;

        this.initEvent(this.district);
        district.value = "";
        Dom.get(this.district.hideInput).value = "";

        this.updatePcdText();
        if (this.callBack && YAHOO.util.Lang.isFunction(this.callBack)) {
            this.callBack("city", data, matchEl);
        }

    },
    /*
    * ssharing.hint为其添加了focus和blur事件,这里为了兼容FF下不显示列表的BUG
    */
    fixHintCompliant: function (o) {
        o.value = " ";
        setTimeout(function () { o.focus(); }, 100);
    },
    districtWorkContent: function (ev, matchEl) {
        this.districtMouseDownHandle(ev, matchEl);
        this.fixValueColor(Dom.get(this.district.textBox));
    },
    /*
    * ssharing.hint为其添加了blur事件用于改变文字颜色
    * 选中列表修改文本框是在mousedown事件中进行的.
    * 事件执行顺序是 先blur再 mousedown 所以 改变文本框值之前 
    * blur事件已经对齐文本判断过了.具体效果可以注释此方法里的内容查看效果
    */
    fixValueColor: function (o) {
        o.style.color = "black";
    },
    districtMouseDownHandle: function (ev, matchEl) {
        var data = this.setControlValue(matchEl, this.district);

        if (data.name != this.districtHistory) {
            Dom.get(this.district.hideInput).value = data.id;
            Dom.get(this.district.textBox).value = data.name;
        }

        this.cityHistroy = data.name;

        this.updatePcdText();
        if (this.callBack && YAHOO.util.Lang.isFunction(this.callBack)) {
            this.callBack("district", data, matchEl);
        }

    },
    setControlValue: function (el, forWho) {
        var id, data;
        if (arguments.length >= 2) {
            id = el.id.substring(8);
            data = this.findDataById(id, this.data);

            return data;
        }
    },
    hide: function (forWho) {
        Dom.setStyle(forWho.container, "display", "none");
    },
    initEvent: function (forWho) {
        var self = this, ul = Dom.getElementsByClassName(this.ULCLASSNAME, "ul", forWho.container),
                fn;
        ul = ul[0];
        Event.on(forWho.textBox, "focus", this.FocusHandle, forWho, this);

        Event.on(forWho.textBox, "blur", function (ev, args) {
            self.hide(args.target);
        }, { target: forWho });

        if (this.province === forWho) {
            fn = this.provinceWorkContent;
        }
        if (this.city === forWho) {
            fn = this.cityWorkContent;
        }
        if (this.district === forWho) {
            fn = this.districtWorkContent;
        }
        Event.delegate(ul, "mousedown", fn, this.MouseDownFilter, this, true);
    },
    MouseDownFilter: function (target) {
        if (target.tagName.toLowerCase() == "a") {
            return target;
        }
    },
    /*
    * 更新详细地址
    */
    updatePcdText: function () {
        var province = Dom.get(this.province.textBox).value,
                    city = Dom.get(this.city.textBox).value,
                    district = Dom.get(this.district.textBox).value,
                    value = "";
        if (province != this.province.defaultText) {
            value += province;
            if (city != this.city.defaultText) {
                if (province != city) {
                    value += city;
                } else {
                    value = city;
                }
                if (district != this.district.defaultText) {
                    value += district;
                }
            }
        }
        if (value != "") {
            Dom.get(this.pcdText).innerHTML = value;
        }
    },
    setData: function (data) {
        if (data && YAHOO.util.Lang.isArray(data)) {
            this.data = data;
        }
    },
    createHtml: function (forWho, data) {
        var i, len, item, html = ["<ul class='address-ul'>"];
        if (data && YAHOO.util.Lang.isArray(data)) {
            for (i = 0, len = data.length; i < len; i += 1) {
                item = data[i];
                html[html.length] = "<li><a id='address_" + item.id + "' href='javascript:void(0)'>" + item.name + "</a></li>";
            }
        }
        html[html.length] = "</ul>";
        forWho.container.innerHTML = html.join('');
    }
}
//创建浮动在文本框内部右侧的提示文字
/*
target:     文本框ID
content：   提示内容
w:          提示内容宽度
*/
ssharing.floatingTips = function (target, content, w) {
    this.tag = "span";
    this.span = null;
    this.target = Dom.get(target);
    this.content = content;
    this.width = (!!w && Lang.isNumber(w) && w) || 30;
    this.init();
}
ssharing.floatingTips.prototype = {
    /* 初始化 
    * target文本框ID 或者DomElement
    * content 初始化提示内容 String
    */
    init: function () {
        target = this.target;
        width = this.width;
        if (!target) {
            return;
        }
        span = this.span = document.createElement(this.tag);
        if (this.content) {
            this.setContent(this.content);
        }
        var elWidth = Dom.getStyle(target, "width");
        Dom.setStyle(target, "width", (parseInt(elWidth) - width) + "px");
        Dom.setStyle(target, "paddingRight", width + "px");

        //span.style.cssText = "background-color:#fff;position:absolute;color:#999;text-align:right;width:40px;padding-right:3px;height:" + target.clientHeight + "px;line-height:" + (target.clientHeight + 2) + "px;margin-left:" + (target.clientWidth - 43) + "px;";
        span.style.cssText = "margin-top:1px;background-color:#fff;position:absolute;*margin-top:3px;_margin-top:2px;color:#666;text-align:right;width:" + width + "px;padding-right:3px;height:" + (target.clientHeight - 2) + "px;line-height:" + target.clientHeight + "px;margin-left:" + (target.clientWidth - width - 2) + "px;";


        Event.on(span, "mousedown", this.stopCapture);
        Event.on(span, "mouseup", this.reCapture);
        Event.on(span, "click", function () {
            target.focus();
        });
        target.parentNode.insertBefore(span, target);
    },
    /*改变提示文字*/
    setContent: function (html) {
        this.span.innerHTML = html;
    },
    /*设置事件捕获*/
    stopCapture: function (e) {
        var t = Event.getTarget(e);
        t.setCapture && t.setCapture();
        Event.preventDefault(e); //防止FF可以选择提示内容
    },
    /*还原捕获*/
    reCapture: function (e) {
        var t = Event.getTarget(e);
        t.releaseCapture && t.releaseCapture();
    }
}
//输入框默认值 J
function onFocus(element,elementValue) {
		if(element.value == elementValue) {
				element.style.color = "";
				element.value = "";
			}
	} /* 得到焦点时触发*/
function onBlur(element,elementValue) {
		if(element.value=="") {
			element.style.color = "#999";
			element.value = elementValue;
			}
		
		
	}




